Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross detection in image

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?

like image 538
Ben Avatar asked Dec 28 '22 09:12

Ben


1 Answers

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.
like image 162
halirutan Avatar answered Jan 01 '23 17:01

halirutan