% read in a jpg image
%
z=imread('Paraglider.jpg');
size(z)
%
% separate out the red, blue, and green components
%
r=z(:,:,1); % r=z(rows, columns, first page)
b=z(:,:,2);
g=z(:,:,3);
%
% look at the components
%
figure(6),clf
subplot(2,2,1),imshow(z),title('composite')
subplot(2,2,2),imshow(r),title('red')
%
% recombine components
%
figure(7),clf
subplot(2,2,1),imshow(cat(3,r,b,g)),title('r,b,g')
%
% write an image to a jpg file
%
outimage=cat(3,g,r,b);
imwrite(outimage,'ParaGRB.jpg')
Best Answer