%% Convert RGB Colormap to Grayscale Colormap Using cmap2gray
% Load an indexed image with its colormap into the workspace. The load command returns a structure containing the image data and the colormap. View the image.

indImage = load('clown.mat');
figure
imshow(indImage.X,indImage.map)

% Convert the RGB colormap that came with the image into a grayscale colormap.

newmap = cmap2gray(indImage.map);

% Display the image with the grayscale colormap.

figure;
imshow(indImage.X,newmap)

% Copyright 2020 The MathWorks, Inc.