主要是引用 rgb2gray函数,将3通道的彩图 转换成 2通道的灰度图像
法1:3通道变成2通道
%%%%%%%%%%%%%%%%%%%%%%%%%%%%=============================
imgname='E:\1.bmp';
[imagRGB] = imread( imgname ); %定义图像名称为imagRGB
subplot(2,2,1);
imshow([imagRGB]);
title('原始图像');
if (length(size(imagRGB)) > 2) %判断通道
imagGray = rgb2gray(imagRGB);
else
imagGray = imagRGB;
end
%clear('imagRGB');
data = double(imagGray);
data =flipdim(data,1);
% Flip linear dimensions (image coordinate system starts at upper left
% corner )
subplot(2,2,2);
imshow(imagGray);
%colormap(map);
title('灰度图像');
法2: <