|
From: Stefan v. d. W. <st...@su...> - 2006-08-14 23:24:29
|
On Mon, Aug 14, 2006 at 11:12:29AM -0700, Christopher Barker wrote: > Another (or additional) option is for both MPL and wx to support the ne= w=20 > array interface protocol in numpy. There's a lot of other reasons to do= =20 > that, and, again, Robin has expressed his support for this. If we could= =20 > get MPL, wx, numpy, and PIL all passing data around with this protocol,= =20 > we'd be in great shape. Travis posted a patch to PIL for support a whil= e=20 > back, I don't know if it's going to get applied or not, but it's worth=20 > looking at. Looks like it has been added already. From http://effbot.org/zone/pil-changes-116.htm - 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 =3D Image.open('lena.jpg') a =3D numpy.asarray(i) # a is readonly i =3D Image.fromarray(a) Regards St=E9fan |