average of PIL images

7stud bbxx789_05ss at yahoo.com
Tue Feb 19 03:55:03 EST 2008


On Feb 19, 12:13 am, "Gabriel Genellina" <gagsl-... at yahoo.com.ar>
wrote:
> En Tue, 19 Feb 2008 04:01:04 -0200, vaneric <vaneric... at gmail.com>  
> escribió:
>
> > On Feb 19, 1:38 am, Robert Kern <robert.k... at gmail.com> wrote:
> >> Averaging color
> >> images is tricky; you really shouldn't do it in the RGB colorspace.
>
> > hi,
> > thanx for the guidance and detailed replies..I  tried  to pack the
> > r,g,b into a single value like below(something a member posted in the
> > past)
>
> > def rgbTopixelvalue((r,g,b)):
> >    alpha=255
> >    return unpack("l", pack("BBBB", b, g, r, alpha))[0]
>
> That's much worse than averaging the R,G,B components. First, you have to  
> omit the alfa value (or set it at the end). Then, consider this example:  
> (0,0,0)=black and (0,1,0)=almost black, average = (0,0,128)

How do you arrive at that average?



More information about the Python-list mailing list