average of PIL images

vaneric vaneric001 at gmail.com
Tue Feb 19 03:28:10 EST 2008


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

oops!
the intention was to pack r,g,b components into a single value sothat
calculations like finding covariant matrix of a set of images etc can
be done..(i need to represent each image as an array of  values(either
long or float)..i can't work with an array of tuples of ints..

> As said above, try to compute using another color space, try HSL. The
> colorsys module can transform from/to RGB.

even if i convert from rgb to hsl i will have a tuple(h,s,l) for each
pixel and again i will have to convert it into a single value which i
can use in matrix multipln etc

is there a workaround sothat rgb color images can be worked on? any
advice most welcome..




More information about the Python-list mailing list