Am Mittwoch, 30. August 2006 19:20 schrieb Ghalib Suleiman: > I'm somewhat new to both libraries...is there any way to create a 2D > array of pixel values from an image object from the Python Image > Library? I'd like to do some arithmetic on the values.
Yes. To transport the data: >>> import numpy >>> image = <some PIL image> >>> arr = numpy.fromstring(image.tostring(), dtype=numpy.uint8) (alternately use dtype=numpy.uint32 if you want RGBA packed in one number). arr will be a 1d array with length (height * width * b(ytes)pp). Use reshape to get it into a reasonable form. HTH, Johannes ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion