3

I am new to image processing.
I currently have an image buffer encoded in Mono8.

I am trying to display it using a wx.Bitmap. However, I only find documentation for RGB, RGBA or PNG.

  • Is there any way to convert a Mono8 buffer to another format displayable by a wx.Bitmap()?
  • Is there another widget able to display a Mono8 image buffer?
DRz
  • 1,078
  • 1
  • 11
  • 29
  • 1
    these are the supported image formats http://www.wxpython.org/docs/api/wx.Image-class.html#__init__ ... you will need to use some other tool to convert your mono8 into a wx.Bitmap understandable format – Joran Beasley May 16 '16 at 20:06
  • So, should I look for converting Mono8 to each of these formats until I find one that fits? Where can I learn about differences between these formats? – DRz May 16 '16 at 20:13
  • imagemagic should be able to (I think i saw a note about that ...) you also might be able to use OpenCV to convert it in python ... you just need to convert it to any of those formats ... not sure what you mean by convert it to each until it fits ... you dont know what a GIF or JPEG is? – Joran Beasley May 16 '16 at 20:20
  • I meant: can I convert to any of these format (hence, just have to find how) or should I find one that will "accept to convert from Mono8 to it"? I just know they are file extensions with more or less compression... that's it – DRz May 16 '16 at 20:26

1 Answers1

2

I have found how to do it:

Mono8 is just a table of pixel's value from 0 to 255 on a grayscale.
RGB is that same table according to other colors (Red, Green and Blue).

So, the same image has 3 times more values in RGB than in Mono8.
=> Repeat the same value for each pixel's component.

rgb = [ v for v in image_buffer for _ in range( 3 ) ]
rgb_ba = bytearray( rgb )
bitmap.FromBuffer( height, width, rgb_ba )

Thanks to Martijn Pieters for the help on the list comprehension!

Community
  • 1
  • 1
DRz
  • 1,078
  • 1
  • 11
  • 29