what is the difference between RGB image separation and extraction?

In digital image processing what actually happens when separating the R,G,B components and when extracting them.In RGB separation i come up with three complete red , green and blue images whereas in RGB extraction i get three different gray scale images.What actually happens.and i don't even know if I were right.Can someone explain please?

 Accepted Answer

dhahira - I suspect that your algorithm to separate the image into its RGB components is creating three 3D matrices whereas your algorithm for RGB extraction is just creating three 2D images. For example,
img = uint8(randi(255,100,100,3));
% RGB separation
rSep = uint8(zeros(100,100,3)); rSep(:,:,1) = img(:,:,1);
gSep = uint8(zeros(100,100,3)); gSep(:,:,2) = img(:,:,2);
bSep = uint8(zeros(100,100,3)); bSep(:,:,3) = img(:,:,3);
Note how each of the above is a 3D matrix with all but the colour dimension (copied from img) being set to zero. This will ensure that the red separated image is red, etc. For the other, I suspect that each RGB band is extracted like
% RGB extraction
rExt = img(:,:,1);
gExt = img(:,:,2);
bExt = img(:,:,3);

4 Comments

Simpler and faster to call zeros with the class name:
zeros(100,100,3,'uint8')
thank u for sparing ur time sir, so is this the same as
img(:,:,2:3)=0; % for separating red
img(:,:,3:1)=0; % for separating green
img(:,:,1:2)=0; % for separating blue
end
and i suppose that in image extraction just the red channel is extracted and is made into a 2 D gray scale image whose intensities are proportion to the distribution of red on the RGB image??
You'd want [1,3] for green, not 3:1.
gSep = uint8(size(img)); % More general & robust than uint8(zeros(100,100,3))
img(:,:, [1, 3])=0; % for separating green
Again, this is still an RGB image, just that the red and green channels are zeroes out, so I'm not really sure how this separates green. I mean, you still have the full size red and blue channels hanging around onto gSep and taking up memory. But if that's how your instructor defines it, then whatever....

Sign in to comment.

More Answers (1)

To me, there is no difference. They're just different words used to explain the same thing. You can extract, separate, isolate, pull out, or whatever word you want to use, the individual color channels using code like this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
Each of those arrays on the left hand side is a 2D array -- a single valued, gray scale, monochrome array. Even though they represent color channels, by themselves they are not color. If you display them with imshow() they will show up as a gray scale image, unless you apply a color channel. So to me the only difference is the verb/word that is being used to describe the same operations. Just like gray level image, gray scale image, and monochrome image all describe the same thing. Now other people may define extract and separate differently, and if so, they should give their definition some place.

1 Comment

i don't know but we are asked to do RGB separation and RGB extraction as two different exercises in our lab session and were told that they were different

Sign in to comment.

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!