Search code examples
image-processingwolfram-mathematicatext-recognition

Mathematica's TextRecognize not up to par


Please take a look at the screenshot below and see if you can tell me why this won't work. The examples in on the reference page for TextRecognize look pretty impressive, I don't think recognizing single letters like this should be a problem. I've tried resizing the letters as well as having the image sharpened.

For convenience in case you want to try this yourself I have included the image that I use at the bottom of this post. You can also find plenty more like this by searching for "Wordfeud" in Google Image Search.

Mathematica screenshot

Wordfeud board


Solution

  • Very cool question!

    TextRecognize uses heuristics to recognize whole words from the English language. This is the gotcha that makes recognizing single letters very hard

    Consider the following line of thought:

    s = Import["https://i.sstatic.net/JHYuh.png"];
    p = ImagePartition[s, 32]
    

    Now pick letters to form the English word 'EXIT':

    x = {p[[1, 13]], p[[6, 6]], p[[3, 13]], p[[1, 12]]}
    

    Now clean up these images a bit, like so:

    d = ImageAssemble[ Map[ImageTake[#, {3, 27}, {2, 20}] &, x ]];
    

    Then this returns the string "EXIT":

    TextRecognize[d]
    

    Mathematica graphics