Take the 2-minute tour ×

I am integrating Tesseract OCR in an app. Unfortunately the quality of the recognition is... not that great. The answer seems to be doing some very basic image cleaning before sending the image off for OCR.

Basically I plan to build a small pipeline that does the following:

  1. Crop to a white bounding box on the assumption that most users will try to do recco of ordinary black print on white background (optional)
  2. Convert to black/white
  3. Despeckle to remove artifacts caused by step 2.

I have 2. down (the easy part), and am looking for input on how to do 3 and optionally 1.

share|improve this question
Yes, but I was hoping for a Core Image solution, so I could avoid including yet another library in my app. –  Anders Johansen Aug 14 '13 at 9:38
Then maybe some combination of median filtering and noise reduction. –  Martin Aug 14 '13 at 9:51
add comment

1 Answer

up vote 0 down vote accepted

Well... It turns out that Martin's suggestion of using ImageMagick is probably the best option in my case.

There's a CI filter that does noise removal, but it's not available in iOS, and I will have to use ImageMagick to convert a PDF to TIFF for OCR anyway, so ImageMagick it is.

An alternative is the small image processing library that Chris Greening made. If you don't need the full force of ImageMagick it will do most of the light lifting for you, and some of the heavy lifting too.

share|improve this answer
There's also my open source framework here: github.com/BradLarson/GPUImage , which should let you do a few types of thresholding (adaptive and not), as well as a few operations that might help with despeckling. A median filter, or an opening or closing one (I can't remember which one operates best on light or dark content), could do what you want. Additionally, you can write your own custom filters based on fragment shaders to use there. It might be a little easier to incorporate than ImageMagick (and probably more performant, being on the GPU). –  Brad Larson Aug 27 '13 at 19:40
add comment

Your Answer


