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
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
im2double for example. For an automatic threshold, consider
bw = im2bw (img, graythresh (img));
See also: graythresh, ind2gray, rgb2gray.