| Image Processing Toolbox™ | ![]() |
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 image 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). You specify level in the range [0,1], regardless of the class of the input image. The function graythresh can be used to compute the level argument automatically. If you do not specify level, im2bw uses the value 0.5.
BW = im2bw(X, map, level) converts the indexed image X with colormap map to 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, im2bw converts the input image to grayscale, and then converts this grayscale image to binary by thresholding.
The input image can be of class uint8, uint16, single, int16, or double, and must be nonsparse. The output image BW is of class logical.
load trees BW = im2bw(X,map,0.4); imshow(X,map), figure, imshow(BW)

graythresh, ind2gray, rgb2gray
![]() | ifftn | im2col | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |