using PIL for PCA analysis

Jan Erik Solem jesolem at
Tue Jan 13 11:16:35 CET 2009

> if i want to do an array of PIL image data i can use
>"myimg.jpg") .convert("L")
> pixelarray=img.getdata()
convert("L") is a good way to make images grayscale. An option to using
getdata() is to try numpy's array:
pixelarray = numpy.array(img)
this gives lots of possibilities for working with the images numerically,
like for PCA. (see example code in the link below)

> 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?
I wrote a short script for doing PCA on images using python, with some
explanations and example code here .
Could be of help to you guys. 

View this message in context:
Sent from the Python - python-list mailing list archive at

More information about the Python-list mailing list