How to remove unclosed lines in a boundary image

2 views (last 30 days)
Hello, everyone. I met a problem when I fused two boundary images from different sources (one is from the function "boundarymask" based on a binary image and another is from canny edge detection). When focusing on one closed polygon, there may exist multiple lines (closed or not closed) internally. So is anyone know how to remove isolated lines within a closed ploygon? Like the following red rectangle region:
there may exist multiple isolated lines in a closed polygon. How to remove it while keeping closed lines which connect to th outer boundary. Please help me. Thanks a lot
  3 Comments
set laura
set laura on 3 Apr 2019
Thanks a lot. But my question is to remove isolated lines exsiting in an closed boundary while keeping closed lines. If imfill is used, then "closed lines" within this boundary will be ignored.
I tried the following solutions:
1) apply boundarymask to enlarge boundaries. This keeps closed regions.
2) then use imfill to fill gaps and remove isolated lines
but the above method may enlarge the boundaries of the origional image
Akira Agata
Akira Agata on 8 Apr 2019
Thank you for the clarification!
OK, then, how about the second possible solution?
> (2) Calculate Euler number for each region using regionprops function, and then, remove the region whose Euler number = 1 (= region w/o hole = should be isolated line).

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!