Remove the unwanted region from an image....
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162163/image.png)
0 comentarios
Respuestas (1)
Image Analyst
el 26 de Mzo. de 2017
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 comentarios
Piyum Rangana
el 26 de Mzo. de 2017
Editada: Piyum Rangana
el 26 de Mzo. de 2017
Image Analyst
el 27 de Mzo. de 2017
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.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!