Ask Your Question

Shape matching for a total newbie

asked 2013-02-12 09:30:30 -0500

vonpupp gravatar image

Hello Everybody,

I've been asked to participate into an academic psychological project. The area I should help would be in trying to evaluate a series of tests through computer vision. The evaluation is quantitative and qualitative. In this first phase I'm focusing just in the quantitative analysis which it should be "easier". I would like to implement this in python, but the problem is that I don't have any knowledge in CV.

To illustrate this better here is a screenshot:

Each octagon is an answer, and the shape I have to identify is formed by the combination of straight lines connecting the numbers. There are 6 possible lines (1-2, 1-3, 1-4, 2-3, 2-4, 3-4), so there should be 2^6 = 64 possible shape patterns (63 valid ones, excluding the blank one).

What I have to do is a count on: - How many different (unique) shapes are within a test - How many repeated shapes are - How many mistakes (ie, circles, a "T" shape, curves or anything that doesn't match the 63 accepted ones).

There are some acceptance criteria that hasn't been defined yet, for instance a very short line shouldn't be accepted, and a long one that even goes over the numbers could be accepted.

I first thought of identifying straight lines with HoughLinesP, but it doesn't seems to work well, since the lines are human made and therefore not perfect.

I should perhaps first decompose the full test into partial images (per answer), to analyze them in a separated way. I don't know how to do this, I thought of applying some sort of color mask during the scanning process so I can just keep the white regions.

For patterns identification I've read something about SIFT and cvMatchTemplate (keep in mind that I'm totally new to this CV area), but I'm not sure if these approaches could effectively solve the problem.

I think that some sort of artificial intelligence and training is needed but perhaps there are easier approaches.

Any help, guidance or even example code would be greatly appreciated!

Thanks a lot!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-02-12 09:49:21 -0500

Here is a small approach I will use in your case:

  1. Find octagon by template matching (doc). Use an empty octagon for template.
  2. subtract the empty octagon for each founded => you have ``only'' the lines made by user (and some noise remove with a threshold on white value, may be convert the image in HSV before doing the subtraction with cvtColor.
  3. In the binary mask coming from subtraction, count the pixels along all potential lines (1-2,1-3,...) using an acceptable width, ie: count not only for a line of one pixel, but for 5 or 6 thick. If the value is high (to determine by samples...) => you have a connection between numbers.

To avoid problem when you count a pixel for a line, remove it from the mask if the line is accepted.

If the line are too thin, try morphological maths to emphasized it with this.

Let us know if it working.

edit flag offensive delete link more

Question Tools


Asked: 2013-02-12 09:30:30 -0500

Seen: 1,081 times

Last updated: Feb 12 '13