3

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

enter image description here

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

But the result is wrong.

Import["https://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?

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

1 Answers1

2

Based on corey979's comment I found this solution:

TextRecognize@
GaussianFilter[#, 4] &@
ImageResize[#, Scaled[3]] &@
ImagePad[#, 4, White] &@
Import["https://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.

DPF
  • 1,067
  • 8
  • 19
  • 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. – corey979 Sep 24 '16 at 12:55
  • 1
    @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. – Rolf Mertig Sep 24 '16 at 14:13
  • @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. – DPF Sep 25 '16 at 09:11