[Image-SIG] Image file to numeric representation

Fredrik Lundh fredrik@pythonware.com
Wed, 14 Apr 1999 21:23:24 +0200

Ken N. Seergobin wrote:
> I have what is probably a very simple question...
> Once an image has been opened, how does one go about converting
> the internal format to a numeric representation that can
> be analyzed?  As an example, I would like to assess the pairwise
> correlation of various images.  

here's one way to do it:

    im = Image.open("data.pgm")
    data = list(im.getdata())

data is now a "flattened" list containing
the pixels for the first row, followed by
the second row, etc.

also see the various posts on PIL/NumPy

Cheers /F