Image Preprocessing steps to improve the recognition rate

谁说胖子不能爱 提交于 2019-12-04 10:05:26

问题


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/


回答1:


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):

 




回答2:


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:

 


 




回答3:


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

 



来源:https://stackoverflow.com/questions/12006866/image-preprocessing-steps-to-improve-the-recognition-rate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!