Image Processing Toolbox User's Guide |
Rearrange the colors in a colormap
Syntax
Description
[Y,newmap] = cmpermute(X,map)
randomly reorders the colors in map
to produce a new colormap newmap
. The cmpermute
function also modifies the values in X
to maintain correspondence between the indices and the colormap, and returns the result in Y
. The image Y
and associated colormap newmap
produce the same image as X
and map
.
[Y,newmap] = cmpermute(X,map,index)
uses an ordering matrix (such as the second output of sort
) to define the order of colors in the new colormap.
Class Support
The input image X
can be of class uint8
or double
. Y
is returned as an array of the same class as X
.
Example
To arrange a colormap in order by luminance, use
This example orders a colormap by luminance.
load trees ntsc = rgb2ntsc(map); [dum,index] = sort(ntsc(:,1)); [Y,newmap] = cmpermute(X,map,index); figure, imshow(X,map) figure, imshow(Y,newmap)
See Also
randperm
, sort
in the MATLAB Function Reference
checkerboard | cmunique |
© 1994-2005 The MathWorks, Inc.