Eliminate duplicate colors in colormap; convert grayscale or truecolor image to indexed image
[Y,newmap] = cmunique(X,map)
[Y,newmap] = cmunique(RGB)
[Y,newmap] = cmunique(I)
[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:
|
[Y,newmap] = cmunique(I)
converts
the grayscale 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
.
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
.