Ask Your Question

Enhancing low-contrast detail

asked 2019-04-15 06:16:18 -0500

ThePromenader gravatar image

I'm new to openCv, so apologies if I have overlooked an obvious method (that I obviously haven't found yet).

My goal is to 'clean' an image of scanned text in preparation for an OCR-esque process: already I have found a method of eliminating page shadow and texture (I can share it, if this is not already common knowledge), but I am stuck at the 'cleaning' of the text itself: an overall satisfactory result results in detail loss, and maintained details results in 'plugged' letters ('R's looking like 'B's in serifed, bold fonts, for example), and the process takes a long time on larger images.


iShadow removed, histogram normalised
Shadow removed, histogram normalised

Page cleaned
Page cleaned

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-04-15 07:28:39 -0500

kbarni gravatar image

updated 2019-04-15 07:41:26 -0500

The Perona-Malik anisothropic diffusion (from the OpenCV extended image processing module) is used a lot for photo denoising. It accentuates linear structures (like the lines), so it will keep the lines from the fonts.

If you want to go further, Olivier Lavialle and Romulus Terebes worked on applying the Perona-Malik method on linear structure enhancement in old documents: Habilitation (see results on page 27) and Thesis.

If you need this step as a preprocessing before OCR, you could use the grayscale image directly with a DNN. A simple network, like the LeNet, already gives excellent results for character recognition even for noisy data.

edit flag offensive delete link more


Thank you so much! That's my goal exactly, looking into it... now. Thanks again!

ThePromenader gravatar imageThePromenader ( 2019-04-15 07:38:19 -0500 )edit

I forgot to mention that I'm in python - the extended image modules weren't ported over to it very well (limited variables (no theta control) and it only works on RGB images). Most of the more interesting image manipulation functions are only in C++ (and only 'ported' to python), so this also an additional motivation to switch. Thanks!

ThePromenader gravatar imageThePromenader ( 2019-04-15 11:50:44 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-04-15 06:16:18 -0500

Seen: 158 times

Last updated: Apr 15 '19