Check if a curve is closed

后端 未结 1 1143
萌比男神i
萌比男神i 2021-01-27 04:58

How can I check efficiently if a curve is closed? For example look this figure:

The curve will always be white on a black background. I tried with flood fill al

相关标签:
1条回答
  • 2021-01-27 05:39

    The way to see if the boundary in your image is closed is by doing a flood fill of the boundary starting at all the image edge pixels. That is, you put all the background pixels that are at the image edge on the queue, then flood fill from there.

    Next, check to see if any background pixels are left. If the flood fill filled inside the object, the boundary wasn’t closed.

    0 讨论(0)
提交回复
热议问题