1

I have a picture that I elaborate with my program to obtain a list of coordinates.

There is a matrix represented in the image. In an ideal test I would get only the sixteen central points of each square of the matrix. But in actual tests I have some noise points.

I want to use an algorithm to extrapolate from the list of the coordinates the group formed by 16 coordinates that best represent a matrix.

  • Example of found points:

  • Example of desired result:

How to do this?

Note: The matrix in the image can be rotated a little too, so a rotation-independent algorithm would be great.

Thomas Owens
85.7k18 gold badges210 silver badges308 bronze badges
asked May 23, 2013 at 21:57
4
  • Do you know something more about the matrix structure, e.g. the maximum distance between two points? Commented May 24, 2013 at 8:35
  • @McMannus The matrix is always an 4x4 matrix. In the image is NOT always present the matrix, but is not important, i need to extrapolate the best matching matrix. (of course if i find LESS than 16 points, I will not elaborate it). The distance is not costant. The matrix can be found in any given ratio. Commented May 24, 2013 at 9:53
  • 2
    Well, a first direction for this kind of problem could be Template Matching algorithms en.wikipedia.org/wiki/Template_matching Commented May 24, 2013 at 10:00
  • Another question: Is it too much of a performance draw to first, find all points in the image? (and then determine which ones form the matrix from there) Commented May 24, 2013 at 14:46

1 Answer 1

2

Now I'm using an algorithm that worked very well for me.

This is the pseudo code:

for each pair of points (p1, p2):
 let d be the distance vector (x and y) between them
 if d.x > (image.width-p1.x)/3 or d.y > (image.height-p1.y)/3:
 continue
 let d_t be d turned 90 degrees (d.y, -d.x)
 for i from 0 to 3:
 for j from 0 to 3:
 if there is no point at p1 + i*d + j*d_t:
 continue outer loop
 if you get here, you have a 4*4 grid
gnat
20.5k29 gold badges117 silver badges308 bronze badges
answered Aug 16, 2013 at 18:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.