Re: average of PIL images
def rgbTopixelvalue((r,g,b)): alpha=255 return unpack(l, pack(, 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.. -- http://mail.python.org/mailman/listinfo/python-list
Re: average of PIL images
a) Work with the 3 components in parallel (that is, use 3 separate matrices, one for each component, and regenerate the image at the end). that wd be ok for image generation ..but to calculate covariance matrix from the set of images i don't know if it wd work eric -- http://mail.python.org/mailman/listinfo/python-list
average of PIL images
hi i have a set of RGB images of diff faces (of people )as a 2 dim numpyarray ..something like threefaces=array([[xa1,xa2,xa3], [xb1,xb2,xb3], [xc1,xc2,xc3]]) where xa1,xa2,xa3 are tuples each representing rgb values of a pixel of first image .. i need to create the average face image and display it.problem is i need to calculate (xa1+xb1+xc1)/3 etc to calculate avearge value of each pixel.how can i do this calculation.do i need to convert the r,g,b in to a single value for each pixel? the average value of a pixel will be a float isn't it? how can i create a PIL image from this? any help,directive greatly appreciated eric -- http://mail.python.org/mailman/listinfo/python-list
Re: average of PIL images
On Feb 19, 1:38 am, Robert Kern [EMAIL PROTECTED] 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(, 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 -- http://mail.python.org/mailman/listinfo/python-list
Re: average of PIL images
On Feb 19, 1:38 am, Robert Kern [EMAIL PROTECTED] 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(, 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) here if i use these pixelvalues to create an imag img =Image.fromstring('RGB', (width, height), avgface.tostring()) it will fail because of -'not enough image data'..is there an alternative to create average rgb color image ?(i want to keep the rgb so can't convert to greyscale) is there something wrong with my approach? I am a newbie in PIL/ imageprocessing ..so i would greately appreciate feedback eric -- http://mail.python.org/mailman/listinfo/python-list