Hi!
National Instruments image acquisition devices do not currently support Bayer encoding. In some cases, the manufacturer provides decoding software along with the camera. You might be able to acquire the encoded image with the IMAQ PCI-1422 or IMAQ PCI-1424, then use the manufacturer's software to get a proper color image. Before purchasing a camera or digital frame grabber, always check on the compatibility by checking for it in the Camera Advisor at www.ni.com/camera or contact technical support for the latest updates.
The encoding is tied very closely with the CCD manufaturing, and I have pasted information below from the NI Developer Zone.
Bayer encoding is a method which allows color images to be produced with only 8-bit resolution, as opposed to the typical 24-bit (RGB) representation. By assigning each pixel either a Red, Green, or Blue value, you can use the color information in the vicinity of each pixel to specify the actual color for that pixel.
The decoding scheme is very dependent on how the CCD is manufactured. One very basic algorithm is described below, but you should contact the camera manufacturer to get a more robust decoding scheme.
The goal of these encoders is to get color information with low data throughput. On a typical 3 CCD camera, the camera outputs 24 bits per pixel - 8 bits for each color (Red, Green, Blue). With Bayer encoding, the camera instead sends out only 8 bits per pixel but alternates the colors so that the colors in a neighborhood can be used to determine the value for each color component of the pixel in question.
The output is as follows:
line 0: RGRGRGRGR.....
line 1: GBGBGBGBG.....
line 2: RGRGRGRGR....
line 3: GBGBGBGBG....
.
.
.
The reason there are more green pixels is because the human eye is more sensitive to green, so that amount of data should be maximized. For every pixel, the algorithm must determine a value for the Red, Green and Blue components. Every position contains a particular color component and is surrounded by at least two of each of the other values. A very simple algorithm for decoding involves averaging the neighboring pixels of the same color.
Example:
You want to determine the value of the pixel in line 1, column 3. The pixel in question is in the center of the following group:
RGR
GBG
RGR
And let's say these pixels have the following values:
200 50 220
60 100 62
196 58 198
The Blue component will be the center pixel value, the Green and Red components will be the average of the surrounding green and red pixels, respectively:
R = (200 + 220 + 196 + 198)/4 = 203
G = (50 + 60 + 62 +58)/4 = 58
B = 100
So the final pixel value RGB is (203,58,100). This process is repeated for each pixel in the image.
The reason this algorithm depends on the manufacturer of the CCD is that there may need to be special weightings for each color. It is not likely that in manufacturing a CCD that the pixel designated as red is not actually somewhat sensitive to green and blue. There is always some leaking of colors, and the sensitivity to each color varies depends on the manufacturing process of the sensor.
Hope this helps.
Morten Jensen
Applications Engineer
National Instruments