On 19 feb, 06:28, vaneric <[EMAIL PROTECTED]> wrote: > > > 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..
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). b) Convert to grayscale (and lose the color information) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list