Array of 32 bit floats --> RGB Image --> wx.BitmapFromBuffer

Hi All,

I have several wxPython applications working which display pixel data from a camera. I have to convert the data to greyscale and then create/display the data via wx.BitmapFromBuffer and dc.DrawBitmap. I was curious if there was a quick way to keep that data so it can be displayed in color, similar to what it would look like if I displayed it in iPython with imshow? I believe I have to manually mask bits and populate the RGB array accordingly but I thought I would see if anyone has a better way of doing it.

Thanks for any help or suggestions.

Kind Regards,

Steve

Steve wrote:

I have several wxPython applications working which display pixel data from a camera. I have to convert the data to greyscale and then create/display the data via wx.BitmapFromBuffer and dc.DrawBitmap. I was curious if there was a quick way to keep that data so it can be displayed in color, similar to what it would look like if I displayed it in iPython with imshow? I believe I have to manually mask bits and populate the RGB array accordingly

this is quite easy to do with numpy. See notes from me in the past few weeks about similar topics.

-CHB

···

--
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

This is very easy to do with Pil (Python Imaging Library). Every
imaginable file-based image format can very easily be read and then be
converted to each other, which includes floating point format images.

Can you provide a floating point format sample image of any size ?

Ray Pasco

···

On Jun 16, 7:56 pm, Steve <ghostra...@gmail.com> wrote:

Hi All,

I have several wxPython applications working which display pixel data from a
camera. I have to convert the data to greyscale and then create/display the
data via wx.BitmapFromBuffer and dc.DrawBitmap. I was curious if there was a
quick way to keep that data so it can be displayed in color, similar to what
it would look like if I displayed it in iPython with imshow? I believe I
have to manually mask bits and populate the RGB array accordingly but I
thought I would see if anyone has a better way of doing it.

Thanks for any help or suggestions.

Kind Regards,

Steve

Hi Ray,

I used PIL to create an image from my data (which I will attach - 66 x 66) and it appears to be in color but looks different than I suspect it should. Perhaps I need a different mode. The code I used was the following:

data = numpy.load (“data_float.npy”)

d1 = numpy.fromstring (data, dtype = float32)

pilImage = Image.frombuffer (‘RGBA’, (66,66), d1, ‘raw’, ‘RGBA’, 0, 1)

imshow (pilImage)

I plan to test this with my wx application by converting the PIL image to a bitmap and displaying it with wx.DrawBitmap to see what it looks like.

Regards,

  • Steve

data_float.npy (17.1 KB)

···

On Thu, Jun 17, 2010 at 10:07 AM, WinCrazy pascor@verizon.net wrote:

This is very easy to do with Pil (Python Imaging Library). Every

imaginable file-based image format can very easily be read and then be

converted to each other, which includes floating point format images.

Can you provide a floating point format sample image of any size ?

Ray Pasco

On Jun 16, 7:56 pm, Steve ghostra...@gmail.com wrote:

Hi All,

I have several wxPython applications working which display pixel data from a

camera. I have to convert the data to greyscale and then create/display the

data via wx.BitmapFromBuffer and dc.DrawBitmap. I was curious if there was a

quick way to keep that data so it can be displayed in color, similar to what

it would look like if I displayed it in iPython with imshow? I believe I

have to manually mask bits and populate the RGB array accordingly but I

thought I would see if anyone has a better way of doing it.

Thanks for any help or suggestions.

Kind Regards,

Steve

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en