Reputation: 9359
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:
And,
this one is negative case:
Is there any method in image processing or some algorithm to detect continuous polygon ?
Any kind of help is appreciated.
Upvotes: 3
Views: 3440
Reputation: 3625
If you need to detect both concave and convex polygons, then I can suggest you another way to do it, one has already have been told by @mdh
Of course there may be some errors in self-intersecting polygons, and/or if there are more than one contour in an image, but this may be fixed by a segmentation picking just the bounding box of the contour and apply the algo on each one.
Upvotes: 2
Reputation: 5563
You may wanna look into shapely.geometry.Polygon, in particular the is_valid method.
Upvotes: 2
Reputation: 21203
I hope you know how to find contours.
Using cv2.isContourConvex(contour)
you can identify whether the detected contour is convex or not. By convex, I mean whether the convex is closed or not. You will be able to separate closed and open contours using this function, which return a boolean value True
or False
.
After separating out the contours you go on to perform further analysis deciding whether the contour has edges or not.
Upvotes: 2
Reputation: 305
I had a tool to detect region in image and some properties belonging to that region. https://github.com/mribrahim/Blob-Detection
Think that, if it is a polygon , it will be a closed region (positive case).
If it is not closed,it will be a line (negative case).
You can find regions properties with the blob detection tool, I mentioned. And you can use some properties like eccentricity, solidity to distinguish positive and negative cases.
For example; negative case eccentiricity will be closed to 0, because of it is a line
Upvotes: 1