From: Chris P. <chr...@ro...> - 2004-03-22 22:20:20
|
I would like to make a numarray array that shares data with a Numeric array and/or with a PIL Image. As an example of the sort of thing I want to do: >>> import Numeric, Image, ImageDraw >>> a = Numeric.zeros((8,8), 'b') >>> im = Image.frombuffer('L', a.shape[::-1], a) >>> im.readonly = False >>> d = ImageDraw.Draw(im) >>> d.line((0,0,8,8), fill=255) >>> a array([[ 0, 0, 0, 0, 0, 0, 0, 255], [ 0, 0, 0, 0, 0, 0, 255, 0], [ 0, 0, 0, 0, 0, 255, 0, 0], [ 0, 0, 0, 0, 255, 0, 0, 0], [ 0, 0, 0, 255, 0, 0, 0, 0], [ 0, 0, 255, 0, 0, 0, 0, 0], [ 0, 255, 0, 0, 0, 0, 0, 0], [255, 0, 0, 0, 0, 0, 0, 0]],'b') So with Numeric, I can have bidirectional data sharing between an array and an Image object. I have been unable to do the same using a numarray array. Does anyone know whether there is a way to do this? Chris Perkins |