% party.m reads a file, displays it and its red, green, and blue components F = 'party_72.png'; % specify the file name imfinfo(F) % display image information P=imread(F); % read image into M by N by 3 matrix size(P) class(P) % tell what type of number A contains clf subplot(2,2,1) imshow(P,'truesize'); title('Original image') subplot(2,2,2) Q = P; Q(:,:,2) = min(P(:,:,2),0); Q(:,:,3) = min(P(:,:,3),0); imshow(Q,'truesize'); title('Red component only') subplot(2,2,3) Q = P; Q(:,:,1) = min(P(:,:,1),0); Q(:,:,3) = min(P(:,:,3),0); imshow(Q,'truesize'); title('Green component only') subplot(2,2,4) Q = P; Q(:,:,1) = min(P(:,:,1),0); Q(:,:,2) = min(P(:,:,2),0); imshow(Q,'truesize'); title('Blue component only')