Operators and Keywords

Function List:


Function File: im2bw (img, threshold)
Function File: im2bw (X, cmap, threshold)

Convert image to binary, black and white, by threshold.

The input image img can either be a grayscale or RGB image. In the later case, img is first converted to grayscale with rgb2gray. Input can also be an indexed image X in which case the colormap cmap needs to be specified.

The value of threshold should be in the range [0,1] independently of the class of img. Values from other classes can be converted to the correct value with im2double for example. For an automatic threshold, consider using graythresh.

bw = im2bw (img, graythresh (img));

See also: graythresh, ind2gray, rgb2gray.

Package: image