[Numpy-discussion] display numpy array as image

Christopher Barker Chris.Barker@noaa....
Thu Nov 29 17:19:03 CST 2007


Zachary Pincus wrote:
> wxPython looks pretty easy too, as there are facilities for getting  
> pixels from a buffer. Does anyone have any experience with these? 

some.

> Are  
> there ways of allowing a numpy array and a wxPython image to point to  
> the same memory?

yup. You can build a wxImage from a buffer, and numpy provides a buffer 
interface, so they end up with them sharing the same memory, as long as 
your numpy array is contiguous 24 rgb.

I've enclosed a sample that generates a wx.Image from a numpy array, 
then every time you push the button, the array is altered in-place, and 
you can see the image change.

( think you need at least wxPython 2.8 for this to work)

-Chris








-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ImageNumpy.py
Type: text/x-python
Size: 3823 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071129/fac6ac05/attachment.py 


More information about the Numpy-discussion mailing list