2
$\begingroup$

I have some words want to recognize. For example,I have this image:

enter image description here

Import["http://i.stack.imgur.com/FFYhS.png"] // TextRecognize

But the result is wrong.

Import["http://i.stack.imgur.com/FFYhS.png"] // TextRecognize[ImageResize[#, Scaled[2]]] &

Enlarging the image isn't help to the quality of recognized text.

So how to resolve this problem?

$\endgroup$
  • $\begingroup$ This almost works: TextRecognize@WienerFilter[#, 2] &@ImageResize[#, Scaled[2]] &@ Import["http://i.stack.imgur.com/FFYhS.png"]. It unfortunately mistakes 0 for U. $\endgroup$ – corey979 Sep 24 '16 at 12:37
2
$\begingroup$

Based on corey979's comment I found this solution:

TextRecognize@
GaussianFilter[#, 4] &@
ImageResize[#, Scaled[3]] &@
ImagePad[#, 4, White] &@
Import["http://i.stack.imgur.com/FFYhS.png"]

The GaussianFilter is important to get rid of the "singular" connection of the bars of the 0s. I also added some padding, so that the GaussianFilter can extend the letters outwards.

$\endgroup$
  • $\begingroup$ At the same moment I found TextRecognize @ GaussianFilter[#, 4] & @ ImageResize[#, Scaled[3]] & @ Import["http://i.stack.imgur.com/FFYhS.png"] - it doesn't need ImagePad. $\endgroup$ – corey979 Sep 24 '16 at 12:55
  • 1
    $\begingroup$ @DPF on Windows 10 with Mathematica 11 I get HXMSY8201620001, which is still slightly wrong. I think that TextRecognize, being based on Tesseract, is quite limited. Tesseract has some deep problems, see e.g. this not recognized bug report. $\endgroup$ – Rolf Mertig Sep 24 '16 at 14:13
  • $\begingroup$ @RolfMertig Interesting. You could try to add a Binarize after the GaussianFilter and play with the Gauss range. Of course, some knowledge about the structure of the String would help a lot. $\endgroup$ – DPF Sep 25 '16 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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