[wxpython-users] How to display image from a list

Christopher Barker Chris.Barker at noaa.gov
Thu May 1 14:39:19 PDT 2008


Robert Robert wrote:
> In a quick example I've tried what you said but with the
>  
> import numpy as np
> pixValueList = [0,1,2,3,4,5,6,7,8,9]
> width = 2
> height = 5
> RGB = np.zeros((width, height, 3), dtype=np.uint8)
> RGB[:,:,0] = pixValueList
>  
> I get the error
> ValueError: shape mismatch: objects cannot be broadcast to a single shape
>  
> How do I fill the RGB array correctly. Note that len( pixValueList ) = 
> width * height

oops -- you need to make pixValueList a 2-d array first:

pixValueList = np.array(pixValueList).reshape((width,height))

That's what I get for posting untested code....

-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 at noaa.gov


More information about the wxpython-users mailing list