[Pythonmac-SIG] Re: [Image-SIG] Fixes for PIL enhancers
Dinu Gherman
gherman@darwin.in-berlin.de
Tue, 7 Jan 2003 09:18:21 +0100
Robb Shecter:
> Any suggestions (or more Enhancer implementations!) are appreciated.
Well, I was experimenting with automated enhancers for photographs
and played a bit with the effects of shifting an image's histogram
by some constant offset. (The code below works, but I'm not sure if
this is fully PIL-mantra-compliant?! ;-)
The existing Brightness enhancer is different since it multiplies
pixel values by a factor and the histogram changes its width slight-
ly.
I reckon that it is probably hopeless to try one's hands on fully
automated brightness/contrast enhancement of photographs without
some AI component... But maybe I should try some non-linear ver-
sions, too, before saaying that...
class Shift(ImageEnhance._Enhance):
"An enhancer that shifts the histogram of an image by some offset."
def __init__(self, im):
self.im =3D im
def enhance(self, offset):
return self.im.point(lambda i: i+offset)
Regards,
Dinu
--
Dinu C. Gherman
......................................................................
"Dans la vie, il n'y a pas de solutions. Il y a des forces en marche:
il faut les cr=E9er, et les solutions suivent."
(Antoine de Saint-Exup=E9ry)