4

I have to find the crosses in the image. What I know is the exact position of each red square. Now I have to decide, if there is a cross inside the square or not. What is the best and fastest way to do this? I am using OpenCv/c++! Well, I could try to use the SVM of OpenCv? But is it fast? Do you have any other ideas?

Ben
  • 317
  • 2
  • 6
  • 14
  • Do you want: only the crosses to appear? (as the only objects in the image), or a set of coordinates for each cross? I'd suggest some _clever_ subtraction, and some blob detection. – Sonaten Dec 13 '11 at 20:36

4 Answers4

5

Simple solution: if you know a-priori locations of all boxes, just calculate the average brightness of the box. Boxes with a mark will be much darker than empty boxes.

sastanin
  • 40,473
  • 13
  • 103
  • 130
5

If you really have the coordinates of the center of each number-box and you maybe can adjust the image acquisition a bit, this should be a feasible task. The problem I see here is, that you have a brightness gradient in your image which you should get rid off by either taking a better picture or using a big Gaussian-filter and an image subtraction. Otherwise I'm not sure you'll find a good brightness-threshold to separate crossed from non-crossed.

Another approach you could use is to calculate the variance of your pixels. This gives you a nice local measure, whether or not a dark pen spread your pixel-distribution. A quick test looks promising

lotto processing

Note, that I didn't had the real positions of the boxes. I just divided your image into equally sized regions which is not really correct regarding the box/sub-box like structure. Therefore there are some false positives in it because of the red triangles in each upper left corner and because of some overlapping crosses.

So here's what I did:

  1. Take your image without the red channel and made it a graylevel image.
  2. Filtering this image with a Gaussian of radius 100 and subtracting this from the image.
  3. I divided your image into (7*6)x(7*2) subregions.
  4. Calculated the variance of each subregion and used a variance-threshold of about 0.017 for the above image
  5. Every box which had a larger variance was crossed.
halirutan
  • 4,281
  • 18
  • 44
0

just find rectungles and then do simple pixel compare.

mrgloom
  • 20,061
  • 36
  • 171
  • 301
0

If not detecting red ink is an option, keep it simple: Accumulate all pixels within the red square and threshold on the "redness", i.e. the quotient of the sum of red values divided by the total color values.

thiton
  • 35,651
  • 4
  • 70
  • 100