www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/DisplayImageWithGrayColormapExample.m

    %% Display Image with Gray Colormap
% Load |clown| to get image |X| and its associated colormap, |map|. Display the
% image produced by |X| and |map|. 

% Copyright 2015 The MathWorks, Inc.


load clown 
figure
image(X)
colormap(map)

%%
% Use |contrast| to return a gray colormap that is the same length as the
% current colormap, |map|. Display the image with the new colormap, |cmap|.

cmap = contrast(X);
colormap(cmap)