I want to detect existence of continuous or closed polygon in binary image. The image may contain polygon of variable number of edges and also there may be no polygon at all.

**Here is the positive case:**

[![enter image description here](https://i.stack.imgur.com/ieRki.png)](https://i.stack.imgur.com/ieRki.png)

And, 

**this one is negative case:**

[![enter image description here](https://i.stack.imgur.com/9DaoT.png)](https://i.stack.imgur.com/9DaoT.png)

Is there any method in image processing or some algorithm to detect continuous polygon ?

Any kind of help is appreciated.