I have an image that contains text. Before sending it to OCR, I would like to increase the contrast of it.
The original image is like this:
I can increase the contrast of the text using imagemagick: convert orig.jpg -level 60%x85% contrast.jpg
. This turns the image into
The imagemagick code is basically doing this http://www.imagemagick.org/script/command-line-options.php?#level
In normal usage (-level) the image values are stretched so that the given 'black_point' value in the original image is set to zero (or black), while the given 'white_point' value is set to QuantumRange (or white). This provides you with direct contrast adjustments to the image. The 'gamma' of the resulting image will then be adjusted.
Question
How can I do the same thing in OpenCV? I tried the adjust_gamma
function mentioned in the PyImageSeach blog post http://www.pyimagesearch.com/2015/10/05/opencv-gamma-correction/ but it didn't help my case.