Convert image to binary image, based on threshold
im2bw is not recommended. Use
BW = im2bw(I, level)
BW = im2bw(X, map, level)
BW = im2bw(RGB, level)
BW = im2bw(I, level) converts
the grayscale image
I to a binary image. The output
BW replaces all pixels in the input image
with luminance greater than
level with the value
1 (white) and replaces all other pixels with the value 0 (black).
level in the range [0,1]. This range is
relative to the signal levels possible for the image's class. Therefore,
level value of
0.5 is midway
between black and white, regardless of class. To compute the
you can use the function
If you do not specify
BW = im2bw(X, map, level) converts
the indexed image
X with colormap
a binary image.
BW = im2bw(RGB, level) converts
the truecolor image
RGB to a binary image.
If the input image is not a grayscale image,
the input image to grayscale, and then converts this grayscale image
to binary by thresholding.
The input image can be of class
double, and must be nonsparse. The output image
be 2-D. RGB images are
load trees BW = im2bw(X,map,0.4); imshow(X,map), figure, imshow(BW)