I have a scanned PDF material to which I want to add hidden text layer, so I could index the document. I used ghostscript black and white tiff output device (tiffg4) to extract pages as tiff images, and here is example of what they look like:

enter image description here

Processing this image with tesseract, does not give good results.
Changing ghostscript output DPI (600, 300, 150, 96) shows that image at 96 DPI gives best result from tesseract but it's still not satisfactory.

Now I thought to ask for advice which filter would enhance this image for OCR processing.

I could use imagemagick, or numpy/scipy/ndimage


2 Answers 2


What you really require is probably some morphological operation like dilation followed by erosion. This is called as Closing operation. May be in your case- just dilation itself might be good.

There was a similar question asked previously - which can help with other aspects.

monochrome (1-bit black-and-white) image conversion

How do I reconstruct text from an image using only morphological operations?


you can remove this using a low-pass filter. that's either done in frequency space, or just take the (difference of) gaussian of the image.

gaussian low-pass, then difference of gaussians to sharpen


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.