Image Processing Toolbox User's Guide Previous page   Next Page
im2bw

Convert an image to a binary image, based on threshold

Syntax

Description

im2bw produces binary images from indexed, intensity, or RGB images. To do this, it converts the input image to grayscale format (if it is not already an intensity image), and then uses thresholding to convert this grayscale image to binary. The output binary image BW has values of 1 (white) for all pixels in the input image with luminance greater than level and 0 (black) for all other pixels. (Note that you specify level in the range [0,1], regardless of the class of the input image.)

BW = im2bw(I,level) converts the intensity image I to black and white.

BW = im2bw(X,map,level) converts the indexed image X with colormap map to black and white.

BW = im2bw(RGB,level) converts the RGB image RGB to black and white.

Class Support

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.

Example

See Also

graythresh, ind2gray, rgb2gray


Previous page  ifftn im2col Next page

© 1994-2005 The MathWorks, Inc.