Deskew and filter an image for OCR
android, ocr, tesseract
Solution
ImageMagick can do that. Commandline:
convert \
input.{png,pdf,tif,jpeg,gif,...} \
-colorspace grayscale \
-threshold 50% \
-deskew \
output.{png,pdf,tif,jpeg,gif,...}
`-colorspace grayscale` : helps to also process colored input. `-threshold 50%` : play with the percentage value -- but basically it converts to black + white only. `-deskews` : deskews
However, I'm not sure how easy or difficult it is to build ImageMagick for the Android platform. It's available for Linux, Mac OS X, Windows, Solaris, HP-UX,... so: it multi-platform by design anyway.
Problem
I have made a lot of research and have not found a suitable solution for this. I am programming an Android OCR app. I have already successfully loaded Tesseract and Leptonica and I am successfully taking and processing images as well as converting them to text using OCR. However, the recognition accuracy is not so good. After much tweaking we found out that we were not filtering, cleaning and/or deskewing the image enough to aid Tesseract in the OCR processing. Therefore, I looked on the internet for any library or code that would work for me and use it on Android to no avail. Does anyone know of a library or can provide me some code to aid me on accomplishing this? All I want is to take a bitmap, convert it to black and white, deskew and/or execute some filtering tasks and give it to Tesseract for it to convert it to text using OCR.