| Image Processing Toolbox User's Guide | ![]() |
Convert an intensity image to an indexed image
Syntax
Description
gray2ind scales, then rounds, an intensity image to produce an equivalent indexed image.
[X,map] = gray2ind(I,n) converts the intensity image I to an indexed image X with colormap gray(n). If n is omitted, it defaults to 64.
[X,map] = gray2ind(BW,n)
converts the binary image BW to an indexed image X with colormap gray(n). If n is omitted, it defaults to 2.
n must be an integer between 1 and 65536.
Class Support
The input image I can be logical, uint8, uint16, int16, single, or double and must be a real and nonsparse. The image I can have any dimension. The class of the output image X is uint8 if the colormap length is less than or equal to 256; otherwise it is uint16.
Example
Convert an intensity image into an indexed image and then view the result.
See Also
| getsequence | graycomatrix | ![]() |
© 1994-2005 The MathWorks, Inc.