what is the difference between RGB image separation and extraction?
4 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Geoff Hayes
2016-8-1
编辑:Geoff Hayes
2016-8-1
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 个评论
Image Analyst
2016-8-1
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....
更多回答(1 个)
Image Analyst
2016-8-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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!