Numeric and PIL: 1D array from 2D-tuple

Markus von Ehr markus.vonehr at ipm.fhg.de
Mon Jun 10 06:05:46 EDT 2002


Hi,

I have a 2D tuple (an Image) and want to display it using ImageTk
in PIL.
Numeric.choose throws me an error:

Traceback (innermost last):
  File "<pyshell#14>", line 1, in ?
    res = Numeric.choose(MyImage, mask)
ValueError: invalid entry in choice array

Anybody knows how to get a 1D-array to construct the
ImageTk.PhotoImage?

Thanks for any comments,

Markus

code:

MyImage = self.cam.Image # MyImage is a 2D-tuple

mask = [1 for i in MyImage]

MyImage = Numeric.choose(MyImage, mask)
        
new_image = MyImage.tostring()
self.im.fromstring(new_image, "raw", "RGBX", 0, -1)

self.photoimage = ImageTk.PhotoImage(self.im)



More information about the Python-list mailing list