简体   繁体   中英

How to find “regions” in a contour OpenCV?

Say we have the following contour information from OpenCV contours:

在此处输入图片说明

What I mean by a "region" is a subset of the contour with low directional variation.

So for example these, could be regions in the provided example:

在此处输入图片说明

One way to detect these could be, doing a local neighborhoud comparison of the dot products of the tangent at each point. (ie see how much the tangent changes locally).

I was wondering however if there is a better way to do this, using OpenCV directly rather than doing vector operations myself.

-When your region boundaries are always near-vertical or near-horizontal, consider preprocessing the image using a filter (erode, dilate), to isolate vertices and horices, then merge results, to find an alternating color on region boundaries.

-When your directions go anywhere, it's more complicated ! One option would be to retrieve coordinates from your pixels with the help of Hough lines see

https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_houghlines/py_houghlines.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM