I try to get the corner points of a Quadrilateral from set of points.
The second picture is a bit extreme, but the "quality" of my set of points lay between the frist and the second picture.
First I thought of making an Histogram from over 1-360° and length, two following points describe. The four highest peaks would describe the length of each line. But with that iam losing the order points, just know about degree and length or a line and don't know which position a line belongs to.
Then i thought of merging two following lines if they have more or less the same degree, but i don't know how to handle the noise here or predicting a corner.
Does anyone know of an Algorithm which handle this problem or something similar?
You can treat this as a clustering problem, where the cluster "centers" are actually straight lines. To compute the clustering you can use a k-means algorithm:
To improve the first step you could take your idea of taking a histogram over the angles, and assign each point initially to a bucket that corresponds to the closest peak. Then fit lines to the four buckets, and start iterating.
You can also treat this as an optimization problem: pick 4 points so that the area of the difference (white area inside and black area outside of the quadrilateral) is smallest possible. Generic optimization algorithms probably work, but to make it fast you need a reasonable algorithm to compute areas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With