Remove the unwanted region from an image....

3 次查看(过去 30 天)
I have image with an unwanted area, and I want to remove that area and make a mask(RGB) after that operation. How can I easily do this task ? Note : I have attached an image file in which I need to remove the degraded area from that and create a mask. Thankz

回答(1 个)

Image Analyst
Image Analyst 2017-3-26
To make a mask you can just see where each color channel is bright. That will detect the white areas and make a mask.
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Get a mask of "white" where red, green, and blue are all high at the same location.
mask = redChannel > 240 & greenChannel > 240 & blueChannel > 240;
I don't know what "remove" means. You can't remove it since images must remain rectangular. If you want to "fill" it, you can use regionfill(), passing it the original RGB image and the mask, or you can "crop" it out to another smaller rectangular region. So please give your definition of "remove".
  2 个评论
Piyum Rangana
Piyum Rangana 2017-3-26
编辑:Piyum Rangana 2017-3-26
Thanks for the answer. What I meant from 'Remove' is ignore those pixels and I need to inpaint that area further. How ever I tried with the code and below line
mask = redChannel > 240 & greenChannel > 240 & blueChannel > 240;
not worked for me. I print the 'mask' and the pixel values all get zeros. how can I fix that ?
Image Analyst
Image Analyst 2017-3-27
Sorry, I assumed that you would know to change the 240 value to whatever works. I guessed wrong. So I used the Color Thresholder (on the Apps tab) to determine the "white" for your pixture and this is what I came up with:
mask = redChannel > 206 & greenChannel > 153 & blueChannel > 114;
If you can't finish it now, then let me know.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by