Re: [Pyobjc-dev] Displaying a numpy array
Brought to you by:
ronaldoussoren
|
From: Black <py...@bl...> - 2009-04-01 18:12:06
|
On Mar 31, 2009, at 9:38 AM, Ronald Oussoren wrote: > > On 30 Mar, 2009, at 21:28, Thomas Robitaille wrote: > >> Hello, >> >> I have been using Python for a few months, and have now learned how >> to >> use PyObjC in a basic way to design a Cocoa interface (.nib) for a >> python script. >> >> I am interested in displaying a numpy array or PIL image using the >> interface. Is the way to do this to use an OpenGL view? or an Image >> View? Are there examples of such scripts anywhere? I looked at the >> OpenGLDemo.py example, but could not understand how this could be >> used >> to display the contents of an array. >> >> Any advice would be welcome, > > There will be some code to convert to/from PIL images in a future > release of PyObjC, > but I haven't written that code yet and wouldn't mind if someone > send me a patch > for that ;-). I've played on both sides of the fence, I might be able to do something along those lines - but I make no commitments at the moment, I'm pretty busy right now. > > A kludgy way to display a PIL image is to convert the image to a > string and then > create an NSImage from that. > > I have no personal experience with numpy or OpenGL. AFAIK the OpenGL > stuff > works almost completely through PyOpenGL and the Cocoa bindings in > Cocoa > are just a way to represent a regular OpenGL canvas as a Cocoa object. Yes, the OpenGL stuff just works with PyOpenGL. In fact, displaying a PIL image is pretty simple in OpenGL and the whole ObjC side could be side stepped. I'm curious what is meant by "displaying a numpy array". There are many ways one could "display" an array in OpenGL. If it contains bitmap data then you could just use PyOpenGL again. If it is arbitrary data, one could visualize it by mapping the values to visual glyphs. There is nothing particularly visual about arrays of numbers however, so I'm not sure what is meant by "display the contents"... > > That btw. would be another nice contribution to PyObjC: write an > OpenGL example > that does something more interesting than displaying a solid color. > I guess a rotating > teapot would be appropriate for such an example. I might also be able to provide this. I've certainly done some PyObjC / OpenGL work, and as mentioned above, once you have the context, there is very little that is ObjC related. Again no promises, but I'll put it on my list. > Ronald >> >> Thanks, >> >> Thomas >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Pyobjc-dev mailing list >> Pyo...@li... >> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > ------------------------------------------------------------------------------ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |