[Image-SIG] combining enhancers

Chris Cogdon chris at cogdon.org
Tue Sep 23 14:33:00 EDT 2003

On Tuesday, Sep 23, 2003, at 11:14 US/Pacific, William Baxter wrote:

> Is there a way to combine the output of enhancers in PIL? I'd like 2
> sliders for brightness and contrast to be used for the same image. But
> if I try to use ImageEnhance.Brightness and ImageEnhance.Contrast on 
> the
> same image, they keep resetting, as if it's 2 separate images.

Note that the output of 'enhance' is a new image; it doesn't affect the 
current image So you'd need to do this:

# your image is in 'im'

enh = ImageEnhance.Contrast ( im )
im = enh.enhance ( 1 )

enh = ImageEnhance.Brightness ( im )
im = enh.enhance ( 1 )

Yes, I think this is a little daft. It would have made a LOT more sense 
to be able to pass the image to be enhanced into the 'enhance' method, 
but it appears that some of the filters that are set up need the source 
image as some kind of 'reference'. See the ImageEnhance.py source for 
examples (eg: Sharpness)

If you don't like it, you could always wrap those two statements in 
it's own function :)

    ("`-/")_.-'"``-._        Chris Cogdon <chris at cogdon.org>
     . . `; -._    )-;-,_`)
    (v_,)'  _  )`-.\  ``-'
   _.- _..-_/ / ((.'
((,.-'   ((,/   fL

More information about the Image-SIG mailing list