Hi Travis,
this is a great example of the __array_interface__ usage.
I have spotted some problems after patching the Image.py module and
trying to display an array created from Image in matplotlib.
First issue is a minor one. There is a difference in axis order between
ndarray and PIL:
def _conv_type_shape(im):
shape = im.size[::-1]
typ, extra = _MODE_CONV[im.mode]
if extra is None:
return shape, typ
shape += (extra,)
return shape, typ
The second seems to be more complex and may be a more general. The
memory of string created by self.tostring() seems to be deallocated
before array is created (v 0.9.9.2788, win).
Everything works fine after storing the reference to data, but this
probably should be done somewhere else:
def __get_array_interface__(self):
new = {}
shape, typestr = _conv_type_shape(self)
new['shape'] = shape
new['typestr'] = typestr
new['data'] = self.tostring()
self._str_data = new['data'] # a dirty hack
return new
best,
fw
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/numpy-discussion