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

    %% Convert RGB Image to Grayscale Image
% Read and display an RGB image, and then convert it to grayscale.
%%
% Read the sample file, |peppers.png|, and display the RGB image. 

% Copyright 2015 The MathWorks, Inc.

RGB = imread('peppers.png');
imshow(RGB)
%%
% Convert the RGB image to a grayscale image and display it.
I = rgb2gray(RGB);
figure
imshow(I)