using PIL for PCA analysis

harryos oswald.harry at gmail.com
Tue Feb 26 17:19:12 CET 2008


>Paul McGuire  wrote
> # following approx fromhttp://www.dfanning.com/ip_tips/color2gray.html
> grayscale = lambda (R,G,B) : int(0.3*R + 0.59*G + 0.11*B)
> print [ [ grayscale(rgb) for rgb in row ] for row in sampledata ]


Paul
in PIL handbook ,they mention a Luma transform on page15, under the
im.convert() section..
L = R * 299/1000 + G * 587/1000 + B * 114/1000
is that not similar to what you mentioned?(I am newbie in this area..)
if i want to do an array of PIL image data i can use
img=Image.open("myimg.jpg") .convert("L")
pixelarray=img.getdata()

thus i guess i can build a matrix of a set of  images
is there something wrong in the way i do this above?may be i can use
that to find covariance matrix for the set of images?

H



More information about the Python-list mailing list