Page 1 of 1

normalizing B&W doc with different contrast

Posted: 2017-04-24T06:56:43-07:00
by tmuna
The documents has different brightness regions.

Is there a simple command that will intensify each contrast area to B&W ?
Like the HDR, that can "pull out" details in dark areas;

then the desired result :
Since the document is essentially Black and white (text), the final result should have maximum contrast,
Maximum 4 to 8 colors.

original image:
Image

process by a program called "PageLift"; I couldn't find how it works:
Image

I tried:
-gamma : values 2.0 - 4.0. The image was relatively balanced, but still dark, contrast was low;
-evaluate pow (this is essentially the same)
-log 100 (relatively good results, i don't know how to explain its significance in words)
-level 50 - similar to the gamma results, but more blur
-modul120-90 : different regions differ for each other
-sigmoid - blurry and inconsistent

here's the gamma 3 result:
Image

I have intermediate experiene in ImageMagick.
I couldn't find "HDR Effect" - if such exists.

If possible,
I'd like to get pointers to either options, or scripts,
or (if possible :) ) relevant terminology so I can understand it.

imagemagick 7.0.5
windows 7 via console (CMD)
I can also use bash

__________
*i'd use PageLift for all documents, but it doesn't have command line interface...

Re: normalizing B&W doc with different contrast

Posted: 2017-04-24T07:13:38-07:00
by snibgo
What version of IM? What platform?

There are many methods. Dividing by a blur is often a good start, eg (IM v6, Windows CMD syntax):

Code: Select all

convert ifbn2q.png ( +clone -blur 0x10 ) -compose DivideSrc -composite out.png
Then you can adjust the contrast, reduce to grayscale, reduce the number of colours etc.

Re: normalizing B&W doc with different contrast

Posted: 2017-04-24T13:21:49-07:00
by fmw42
If you are on a unix-like platform, then try my script, text cleaner, at the link below. If on Windows, my script will not work, but try -lat. See http://www.imagemagick.org/script/comma ... ns.php#lat. Something like -lat 25x25+10%. Adjust the 25x25 as desired.