Remove Background from image and select the region of interest
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Animesh
el 14 de Feb. de 2014
Comentada: Image Analyst
el 15 de Abr. de 2014
I have a image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156704/image.png)
and I want to remove the background and select the region of interest and my output should be
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156711/image.png)
How can I do it ? thanks in advance.
0 comentarios
Respuesta aceptada
Image Analyst
el 14 de Feb. de 2014
Look at my color segmentation demos http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
For this image, the background is neutral and the subject is not. So I'd probably convert to hsv with rgb2hsv() and then threshold on saturation to get highly saturated pixels. The background won't get selected. Then get rid of any small regions with bwareaopen, call regionprops, get the bounding box, and call imcrop(). The essential lines are few:
hsv=rgb2hsv(rgbImage);
s = hsv(:,:,2);
foreground = s > 0.2; % Or whatever.
foreground = bwareaopen(foreground, 1000); % or whatever.
labeledImage = bwlabel(foreground);
measurements = regionprops(labeledImage, 'BoundingBox');
bb = measurements.BoundingBox;
croppedImage = imcrop(rgbImage, bb);
or something like that. I didn't test it - that's just off the top of my head.
9 comentarios
Image Analyst
el 18 de Feb. de 2014
Editada: Image Analyst
el 18 de Feb. de 2014
Sounds like just taking the mean color would be good enough to tell which note it is. I don't see any need to do anything fancier or more difficult.
Más respuestas (1)
Anagha
el 15 de Abr. de 2014
Hello,
I'm also facing similar problem. I want to crop the egg image from black background for further image processing. I'm attaching the image. Please help me in this regard. Really urgent!!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174778/image.jpeg)
1 comentario
Image Analyst
el 15 de Abr. de 2014
Please start your own thread. Post your image there and explain why you want to crop. Cropping is not necessary for analysis, so why do you want to crop? Answer in your own, new thread, not here.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!