[FIXED] Simple algorithm for approximation image contour for line segment

Issue

The image contour is a array points. I need to approach two points on each side to create four line segments.

title="Image contour">Image contour


Solution

A possible approach.

Find the convex hull of these points.

Then find the two vertices which are the furthest apart. This gives a first diagonal.

Then find the two other vertices that are the farthest from the first diagonal. This gives a second diagonal.

Now you can just use the quadrilateral formed by these four vertices.

If you want a tighter fit, you can consider the subsets of points in the four quadrants defined by the diagonals, and compute best fit lines, for example by least squares.

enter image description here



Answered By - Yves Daoust
Answer Checked By - Dawn Plyler (sql.easybugfix Volunteer)

Related Posts

Post a Comment