Filling the region within objects with white

4 visualizaciones (últimos 30 días)
jeffin
jeffin el 7 de Jul. de 2017
Comentada: jeffin el 10 de Jul. de 2017
I am trying to do background subtraction and the result of one image is displayed here. There are lot of unfilled region in the region of interest.I have used Imfill command in my code. Can someone suggest me how to fill the black region in the region of Interests.
Kindly suggest me some solutions. Thanks in advance.

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Jul. de 2017
Editada: Image Analyst el 8 de Jul. de 2017
I don't know exactly what "fill the black region in the region of Interests" means. If you want to fill the black regions with black, thus making the white "islands" or "holes" black also (essentially making them disappear), then use bwareafilt() and specify the smallest white blob that you're willing to accept. For example, if you want to remove all blobs smaller than 1000 pixels, do this:
binaryImage = bwareafilt(binaryImage, [1000, inf]);
You could also use bwareaopen().
binaryImage = bwareaopen(binaryImage, 1000);
On the other hand, if you want to remove black holes in white regions, simply use imfill:
binaryImage = imfill(binaryImage, 'holes');
I also don't know what the "region of interest" is in that image. Can you indicate it, perhaps by outlining it in red? If the ROI is only part of the whole image, then you'll need to make a mask somehow, perhaps with poly2mask() or some other method depending on how ROI is defined, then use the mask to erase the non-ROI parts of the image.
binaryImage(~ROIMask) = false; % Erase outside of ROI region(s)
  1 comentario
jeffin
jeffin el 10 de Jul. de 2017
The Small white regions present at the top should be eliminated, while the large region present at the bottom should be filled.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by