Image Processing Toolbox    
cmunique

Find unique colormap colors and the corresponding image

Syntax

Description

[Y,newmap] = cmunique(X,map) returns the indexed image Y and associated colormap newmap that produce the same image as (X,map) but with the smallest possible colormap. The cmunique function removes duplicate rows from the colormap and adjusts the indices in the image matrix accordingly.

[Y,newmap] = cmunique(RGB) converts the truecolor image RGB to the indexed image Y and its associated colormap newmap. The return value, newmap, is the smallest possible colormap for the image, containing one entry for each unique color in RGB. (Note that newmap may be very large, because the number of entries can be as many as the number of pixels in RGB.)

[Y,newmap] = cmunique(I) converts the intensity image I to an indexed image Y and its associated colormap newmap. The return value, newmap, is the smallest possible colormap for the image, containing one entry for each unique intensity level in I.

Class Support

The input image can be of class uint8, uint16, or double. The class of the output image Y is uint8 if the length of newmap is less than or equal to 256. If the length of newmap is greater than 256, Y is of class double.

See Also

gray2ind, rgb2ind


  cmpermute col2im