pkg load image clear clc I1 = imread('lena.bmp'); I2 = imread('baboon.bmp'); I3 = imread('peppers.bmp'); Ir = uint8(zeros(256,256,3)); Ir(:,:,1) = I1; Ir(:,:,2) = I2; Ir(:,:,3) = I3; Ibw1 = 0.33*Ir(:,:,1) + 0.33*Ir(:,:,2) + 0.33*Ir(:,:,3); Ibw2 = 0.30*Ir(:,:,1) + 0.59*Ir(:,:,2) + 0.11*Ir(:,:,3); diagR = diag(Ir(:,:,1)); diagG = diag(Ir(:,:,2)); diagB = diag(Ir(:,:,3)); subplot(2,3,1), imshow(Ir,[0 255]), title('Color') subplot(2,3,2), imshow(Ibw1,[0 255]), title('BW1') subplot(2,3,3), imshow(Ibw2,[0 255]), title('BW2') subplot(2,3,4), plot(diagR), axis([0 256 0 256]), grid on, title('diagR') subplot(2,3,5), plot(diagG), axis([0 256 0 256]), grid on, title('diagG') subplot(2,3,6), plot(diagB), axis([0 256 0 256]), grid on, title('diagB')