ImageEnhance.Contrast - is this fishy or what?
Scott David Daniels
Scott.Daniels at Acm.Org
Tue Jun 16 15:38:52 EDT 2009
Scott David Daniels wrote:
> roop wrote:
>> I was browsing ImageEnhace.py, and found something that I thought was
>> odd in class Contrast:
>>
>> class Contrast(_Enhance):
>> "Adjust image contrast"
>> <broken code>
>> <correct analysis>
> ...
> Good catch [I'll send a copy to the imaging sig]. If you replace class
> ...
Over on image-sig, Fredrik Lundh responded:
> And the award for finding the oldest bug in PIL goes to... (that code
> was last touched in 1996).
>
> I've checked in a last-second fix for 1.1.7 (to be frozen any day soon
> now, promise).
>
> Thanks /F
Congrats, roop, on getting this discovered just in the nick of time.
The code he uses is:
class Contrast(_Enhance):
"Adjust image contrast"
def __init__(self, image):
self.image = image
mean = int(ImageStat.Stat(image.convert("L")).mean[0] + 0.5)
self.degenerate = Image.new("L", image.size,
mean).convert(image.mode)
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list