average of PIL images
vaneric
vaneric001 at gmail.com
Tue Feb 19 00:03:31 EST 2008
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]
if i apply this for all images i can represent each image as an array
of longs instead of tuples.then for a pixel i can calculate the
average value
after this if i do the casting as you advised and create the avg
image
avgface = avgface.astype(numpy.uint8)
img = Image.fromstring('L', (width, height), avgface.tostring())
is there something wrong with my approach? I am a newbie in PIL/
imageprocessing ..so i would greately appreciate feedback
eric
More information about the Python-list
mailing list