How to make an image uniform brightness (using Python / PIL)

I want to take the image of the document that was photographed and make it look like it was scanned. Since the scanner will set a constant light source throughout the document, I want to achieve this effect on the photograph of the document. The desired effect would be to remove any shadows or areas of low light (or at least make them less noticeable) and make the whole photo bright enough.

My first thought was to find the brightest part of the target image, and they made the whole image bright. Assuming even the right algorithm, how would I do it in PIL? Is there a brightness method? etc.?

(This is a continuation of this earlier question .)

+3
source share
4 answers

As a first attempt, try installing the image. Dark areas become black, light areas become white. I have not used PIL, but I assume that there is an easy way to do this.

+2
source

Try ImageChops.screen (image1, image2) with 2 copies of the image. If this is not satisfactory, try some other functions in the ImageChops module.

Alternatively, you can first convert it to shades of gray: ImageOps.grayscale (image).

+2
source

, GIMP. , .

0

? -, , , , . , , . . PIL_usm.gblur(, ), ( ) - - , , . hackcode :

import Image
import PIL_usm
# see http://www.cazabon.com/pyCMS/PIL_usm.html for PIL_usm

img = Image.open(...)
sm = PIL_usm(img, 10)
thr = Image.ImageChops.subtract(img,sm, .001, 128)  
# or whatever works 4u...

OTOH, , .

0

All Articles