MATLAB: Need help with creating or modifying an RGB image.

rgb image

Capture.PNG
% 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

I'm not sure how to separate out the red, blue, and green components of an image like the Paraglider.jpg that I'm using .
As you already showing the same in the code
%Read the image
image1=imread('image file name.format');
r=image1(:,:,1); % This line gives you red component of the image
b=image1(:,:,2); % This line gives you blue component of the image
g=image1(:,:,3); % This line gives you green component of the image
Please response in the comment section only.
Related Question