Image Processing Toolbox | ![]() ![]() |
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
, must be a real, nonsparse array of class logical
, uint8
, uint16
, or double
. It 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
.
See Also
![]() | getsequence | grayslice | ![]() |