Write a MATLAB program for to extract Red, Green, and Blue Component


Code:

clear;
clc;
rgb = imread('d:/matimage/baby.jpg'); % Read image from graphics file
r=rgb;
g=rgb;
b=rgb;
r( : , : , 2 )=0;
r( : , : , 2 )=0;
b( : , : , 1 )=0;
b( : , : , 3 )=0;
g( : , : , 1 )=0;
g( : , : , 2 )=0;
subplot(2,2,1),imshow(rgb),title('original image');
subplot(2,2,2),imshow(r),title('red component');
subplot(2,2,3),imshow(g),title('green component');
subplot(2,2,4),imshow(b),title('blue component');


Output:

No comments

Powered by Blogger.