I have an image that I am developing with my program to get a list of coordinates.
The image shows a matrix. In an ideal test, I would get only sixteen center points of each square of the matrix. But in real tests, I accept quite a few noise points.
I want to use the extrapolation algorithm from the list of coordinates, a group formed by 16 coordinates that best represent the matrix.
The matrix can have any aspect ratio (between the range) and can lead to slight rotation. But there is always a 4x4 matrix. The matrix is โโnot always present in the image, but this is not a problem, I only need a better match. Of course, the based point is always greater than 16 (or I skip)
Example based points:

An example of the expected result:

If anyone can suggest me that there is a preferred way to do this, it would be great.
Im thinking about the Euclidean distance between points.
For each point in the list: 1. calculate the euclidean distance (D) with the others 2. filter that points that D * 3 > image.widht (or height) 3. see if it have at least 2 point at the same (more or less) distance, if not skip 4. if yes put the point in a list and for each same-distance founded points: go to 2nd step.
in the end, if I have 16 points in the list, it could be a matrix.
Any better suggestion?
thanks
source share