Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

16bit Bayer encoded image into 48 bit RGB

I have a 16 bit CCD camera which is bayer encoded to create a 48-bit RGB image.  I can access the data without problems and display a greyscale version of the exposure, but I really want to convert this image to color.  Whenever I pass the 16 bit array into the bayer color decode vi I get an error about incorrect image format.

I checked the forum thread from a couple years back when it seemed Labview did not support 48-bit images: http://forums.ni.com/ni/board/message?board.id=200&message.id=9458&query.id=9744#M9458

The work I do requires the color precision of 16 bit color channels.  Is this absense of funtionality still the case or has this been resolved?  Is there a workaround to modify the bayer vi to correctly produce the 48-bit image?

Thanks,

Steven
Message 1 of 18
(8,929 Views)
Hi Steven,

The IMAQ Bayer Color Decode.vi is hardcoded to produce a 32-bit color image (24 bit RGB plus 8 bit alpha), and therefore cannot accept 16-bit channels.

If you wanted to convert your 16 bit greyscale to 64 bit color, you could encode the image manually.  You must first know which Bayer encoding your camera uses (GBGB::RGRG, GRGR::BGBG, BGBG::GRGR, or RGRG::GBGB),  You could then create an array of color pixel values (based on the original 16 bit image and the Bayer information) and send this to IMAQ ArrayToColorImage, which can write U64 RGB.
Chris Bolin
LabVIEW Partner Program, CLA
Message 2 of 18
(8,896 Views)

Chris,

I work at FLEXTRONICS and we do a lot of Camera Module testing, and a lot of image sensors are moving to 10 and 12 bit BAYER.

Since the "IMAQ Bayer Color Decode.vi" limits you to 8bit demosaicing, are there any planes or current efforts to have support for 16 bit demosaicing to get a U64 RGB image out, and maybe even adding options of interpolation algorithms?

Message 3 of 18
(8,838 Views)
Hi Brain,

The IMAQ Bayer Color Decode function does limit you to 8-bit grayscale images, but there are definitely other ways to convert a Bayer-encoded 16-bit (or 10 or 12) image to a color image.

The
IMAQ ArrayToColorImage function can accept four U16 arrays (RGB and alpha) and write a U64 RGB image.  Before that you can use the IMAQ ImageToArray to convert your 16-bit encoded grayscale image to an array, and build the 16-bit RGB arrays based on your camera's specific encoding.
Chris Bolin
LabVIEW Partner Program, CLA
Message 4 of 18
(8,817 Views)

Yes, I see that, I did not even notice it before.

But this only gets me half way, before I write this interpolated RGB (U16 per plane), I need to interpolate my RAW U16 BAYER Data into RGB.

Do you know of any resources (or actual code) that does an "adaptive interpolation" (which I think is what the "IMAQ Bayer Color Decode.vi" is doing) of U16 BAYER data?

Thanks Chris,

Bryan Moore

Message 5 of 18
(8,799 Views)
Hey Brian,

I realize the dilemma, and unfortunately we don't currently offer any U16 Bayer decode functions.  Therefore, this step would have to be programmed.


Message Edited by Chris_B. on 06-16-2008 06:39 PM
Chris Bolin
LabVIEW Partner Program, CLA
Message 6 of 18
(8,761 Views)

Hello,

 

I've been trying to build this manual 16 bit bayer decoding vi and I've been able to create the three U16bit color planes. I have made some sacrifices--as you will see in the attached vi--but I've been successful in extracting the three color channels and extrapolating the missing pixels using standard Labview vi's.

 

However, I am having difficulties with

 

1.) Constructing the U64 bit array used by IMAQ Array to Color Image.vi

2.) Determining what to use as the Alpha Channel. 

 

Can someone illustrate for me an example of constructing the U64 bit? 

 

Thanks in advance.

 

Anderson 

Message 7 of 18
(8,129 Views)
This might work, you still need to format the arrays to put it into the IMAQ ArrayToColorImage vi.
Message 8 of 18
(8,115 Views)
Try this to convert to U64, it might not be the most efficient but it should work
Message 9 of 18
(8,113 Views)

By shifting the image, you are sacrificing positional accuracy and color accuracy.  Your R, G, and B values at a single pixel will all be from different pixels.  If nothing else, you should add another shift operation that moves everything back to where it started.  Your version will work fine on solid colors, but any time the colors change it won't look so good.

 

Here is a scheme that is a little bit more complex but might work better:

 

Create masks for the R, G, and B planes.  These could be created beforehand and stored.  These masks would have a 1 wherever that color is active and zeroes everywhere else.

 

Combine the original image with each mask, using either multiply or mask.  This will give you an image for each color plane.

 

Use a 3x3 convolution filter to fill in the unknown values.  For R and B, the filter would be [[1 2 1][2 4 2][1 2 1]] with a convolution divisor of 4.  For G the filter would be [[0 1 0][1 4 1][0 1 0]] with a convolution divisor of 4.  You could adjust the divisors to do color balancing.

 

Combine the color planes to get a complete image.  Can this be done with IMAQ combine color planes, or does that only work with 8 bit color planes?

 

Bruce

Bruce Ammons
Ammons Engineering
Message 10 of 18
(8,105 Views)