1
$\begingroup$

So I have the following image:

enter image description here

Using GIMP, I was able to get to here:

enter image description here

  1. Select all white color (with a touch of fuzz)
  2. Invert selection
  3. Cut selection
  4. Invert all color (goes black)

But now I'm stuck...

I want to use something like ocrad to extract the numbers.

ocrad goes crazy when I input the black&white image above.

I'd like to see (the grammar is the numbers 1 to 45 inclusive):

var a = [30,31,32,35,37,40,44];
var b = [6,7,11,15,18,21,22];
var c = [5,11,15,18,23,37,28];

It's worth pointing out that the image

  • is always the same dimensions

  • is always the same orientation

  • therefore, I think I can split the image into three rows relatively robustly

Like so:

enter image description here

(in the above case, I also did an extra step - remove black contiguous regions that have large area. Though I don't know how to do this programatically - I did this by eye in GIMP using the "magic wand" tool).

The above image does OK in ocrad, but it gets into trouble with the ring surrounding the "44".

I'm trying to avoid pattern matching.

Does anyone have any tips? I'm thinking of doing all this in Python/OpenCV/similar.

$\endgroup$

2 Answers 2

2
$\begingroup$

You may want to check PyTesser.
Also, this post Adrian Rosebrock - My Top 9 Favorite Python Libraries for Building Image Search Engines is worth reading.

$\endgroup$
1
$\begingroup$

You stated you didn't wanted to use pattern recognition. But considering the fact that your image has always the same dimensions and therefore the number's pattern are always the same, your best bet is realy to use a matched filter. Juste run 10 matched filter with patterns (0,1,2,...,9), you will have the information of which character is present and where it is, and it will be fast. Then an easy-to-design high level heuristic will give you your wanted variable a, b et c.

$\endgroup$
2
  • $\begingroup$ Thank you for the advice. I think I will take it. Someone else suggested pattern matching to me before. Do you have any recommendations for a decent library? $\endgroup$
    – Eamorr
    Commented Apr 10, 2015 at 8:26
  • $\begingroup$ You don't need any specific library. Just take an images and manualy extract 10 patches corresponding to each numbers. Let's say your patches will be 31*31 pixels. Now, each time you get a new image, convolve each patch with the image, this is just a double for loop. There is only 2 difficulties : How will you handle the dot product when you are on image's edges. And be carefull about energy normalization for each dot product because if you do the dot product of two patches and that one is full of 1, the dot product will be huge even if the paterns don't match. Not hard. ask if you need. $\endgroup$ Commented Apr 10, 2015 at 12:05

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.