ImageEnhance.Contrast - is this fishy or what?

roop roop at
Mon Jun 15 17:08:20 CEST 2009

I was browsing, 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())/
        self.degenerate ="L", image.size, mean).convert

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


More information about the Python-list mailing list