ImageEnhance.Contrast - is this fishy or what?

R

roop

I was browsing ImageEnhace.py, and found something that I thought was
odd in class Contrast:

class Contrast(_Enhance):
"Adjust image contrast"
def __init__(self, image):
self.image = image
mean = reduce(lambda a,b: a+b, image.convert("L").histogram())/
256.0
self.degenerate = Image.new("L", image.size, mean).convert
(image.mode)

Isn't reduce(lambda a,b: a+b, image.convert("L").histogram()) the same
as (image.size[0] * image.size[1]) - just count the number of pixels
in the image? (Afaik, the histogram is a list of 256 elements where
the ith element gives the number of pixels with i as the pixel value
(0 <= i < 256)). Is this actually fishy or have I got it all muddled
up?

Thanks,
roop
 
R

roop

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).
 >

Congrats, roop, on getting this discovered just in the nick of time.

/me takes a bow :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top