3
votes

I am making a simple OCR Android App using TessBaseAPI for my project. I have done some image preprocessing steps like binarization and image inhancement. But their result is 50% to 60%. How can we improve the recognition rate?

I include two sample images.

http://imageshack.us/photo/my-images/94/1school.jpg/

http://imageshack.us/photo/my-images/43/15071917.jpg/

3

3 Answers

3
votes

The following additions to above command works for your second image:

-negate \
-deskew 40% \
+repage \
-crop 393x110+0+0 \

They add appropriate levels of deskewing and cropping to the result, so that Tesseract's life gets a bit easier...

So the complete command should be the following, which produces the correct result on my system:

convert 15071917.jpg            \
   -type grayscale              \
   -negate                      \
   -gamma 1                     \
   -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  \
   -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize \
   -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle \
   -negate                      \
   -deskew 40%                  \
   +repage                      \
   -crop 393x110+0+0            \
    15071917.png                \
&&                              \
tesseract 15071917.png OUT && cat OUT.txt

  Tesseract Open Source OCR Engine v3.01 with Leptonica
    Page 0
    TESCO

This is the original picture (left) with the resulting picture of the modified command (right):  

1
votes

This command works for me for the 1st image file. I'm using ImageMagick version 6.7.9-0 2012-08-17 Q16:

convert 1school.jpg                           \
    -scale 1000%                              \
    -blur 1x65535 -blur 1x65535 -blur 1x65535 \
    -contrast                                 \
    -normalize                                \
    -despeckle                                \
    -despeckle                                \
    -type grayscale                           \
    -sharpen 1                                \
    -posterize 3                              \
    -negate 1school.tif                       \
&&                                            \
tesseract 1school.tif OUT && cat OUT.txt

  Tesseract Open Source OCR Engine v3.01 with Leptonica
    Page 0
     '
    SCHOOL
    ZONE

The 2nd image requires a different command:

convert 15071917.jpg            \
   -type grayscale              \
   -negate                      \
   -gamma 1                     \
   -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  -contrast  \
   -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize -normalize \
   -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle -despeckle \
    15071917.tif                \
&&                              \
tesseract 1school.tif OUT && cat OUT.txt

  Tesseract Open Source OCR Engine v3.01 with Leptonica
    Page 0
    TE§§IO

Ok, the second one was not quite as successful. But you get the idea...

Here are the resulting images. Left are the originals, right results from commands:

1st original modified 1st original
 

1
votes

I learned something new today. With Tesseract 3.01 it seems that the most easy way to get the OCR working became to first deskew the text.

Here is a very simple command, which just shears the image and crops it a bit, but doesn't do any contrast or color changing manipulations to the original:

  convert 15071917.jpg  \
      -background pink  \
      -shear -0x6       \
      -crop 350x80+0+24 \
       tesco.jpg        \
  &&                    \
  tesseract tesco.jpg a  &&  cat a.txt

     Tesseract Open Source OCR Engine v3.01 with Leptonica
     TESCO