Hey Guys,
I extracted the background by using the difference and now I want to work on my mask. The image below is currently mask of the binary image after filling it out with imfill(..'holes'). But unfortunately not everything of the body is filled out. Is there a way to fill out the middle part of the body? Thank you very much.

 채택된 답변

Image Analyst
Image Analyst 2020년 6월 28일

3 개 추천

You could try imclose() followed by imfill()
se = strel('disk', 20, 0);
mask = imclose(mask, se);
mask = imfill(mask, 'holes');
imshow(mask);
or you could try an active contour, like the attached demo.
There are fancier ways if you want to make sure the outer boundary doesn't change, but it's more work and I don't have time for that now. See if one of the two methods I gave above works OK for you.

댓글 수: 3

Benjamin Rahimian
Benjamin Rahimian 2024년 3월 24일
Hey, @Image Analyst, could you please explain the fancier methods mentioned?
Image Analyst
Image Analyst 2024년 3월 26일
I'd dilate it enough to close the gap while still having a hole in the middle. Then I'd invert the image and call imclearborder so that you have only the hole and not the surround. Then I'd dilate the hole the same amount you dilated the original binary image. Then I'd OR that expanded hole with the original binary image that has the original boundaries. That should fill the hole however there might still be some very tiny pinholes in the filled blob so then I'd call imfill again to fill those potential tiny holes.
Benjamin Rahimian
Benjamin Rahimian 2024년 3월 26일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

질문:

2020년 6월 28일

댓글:

2024년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by