>> Img=imread('18.bmp');
[h,w]=size(Img)
IMG1 = double(Img);
IMG2=zeros(h,w);
for i = 1 : h
for j = 1 : w
IMG2(i,j,1) = 4 * IMG1(i,j,1); %RED Channel
IMG2(i,j,2) = 4 * IMG1(i,j,2); %GREEN Channel
IMG2(i,j,3) = 4 * IMG1(i,j,3); %BLUE Channle
if (IMG2(i,j,1) >= 255)
IMG2(i,j,1) = 255;
end
if (IMG2(i,j,2) >= 255)
IMG2(i,j,2) = 255;
end
if (IMG2(i,j,3) >= 255)
IMG2(i,j,3) = 255;
end
end
end
IMG2 = uint8(IMG2); %不转换为8位就无法正常显示
subplot(1,2,2); %分为1行2列的子图显示,并且在2显示调整对比度后的图
imshow(IMG2);
title('Processed Image');
h =
389
w =
1758
试图访问 IMG1(1,587,1);由于 size(IMG1)=[389,586,3],索引超出范围。