Fredrik Lundh wrote:
"matrix" as in?

If you just want to work with the image data as Python sequence, use getdata/putdata, or pixel access objects:

   >>> im = Image.open("image.jpg")
   >>> pix = im.load()
   >>> pix[0, 0]
   (226, 162, 125)
   >>> pix[0, 0] = (0, 0, 0)

or convert to numpy arrays:

# Added “fromarray” function, which takes an object implementing the NumPy array interface and creates a PIL Image from it. (from Travis Oliphant).

# Added NumPy array interface support (__array_interface__) to the Image class (based on code by Travis Oliphant). This allows you to easily convert between PIL image memories and NumPy arrays:

import numpy, Image

i = Image.open('lena.jpg')
a = numpy.asarray(i) # a is readonly
i = Image.fromarray(a)



--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to