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
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.