Tags:
create new tag
, view all tags

Table of Contents

Introduction

A detail of a single bayer quad-pixel

The Bayer Pattern is used to turn a pan-chromatic CCD array into a color-sensitive CCD array. The way this is done is that each of the individual CCD elements are covered with color filters. This is done in a 2x2 repeating pattern of color filters over the pixels. The standard way to do this is as follows;

The first scanline contains CCD elements with Green, followed by Red filters, repeating. Green, Red, Green, Red, etc...

The second scanline contains CCD elements with Blue, followed by Green filters, repeating. Blue, Green, Blue, Green, etc...

This pattern repeats down for all scanlines of the image, like so:

Example of a bayer array

Generally, this is captured into a file where all of these CCD samples are interleaved with eachother, as you see above. If the raw image was to be viewed in an image viewer, it would appear to be a grayscale image with a checkerboard look to it.

Resolution

For example's sake, we'll use the Terrapix image as an example. There are 4096 scanlines of this pattern, containing 4194304 (2048*2048) green pixels, 1048576 (1024*1024) red pixels, and 1048576 (1024*1024) blue pixels in this alternating pattern. (Example images to come soon.)

A full-resolution image can be made of 4096x4096 pixels, containing interpolated colors. A lower-resolution image of 2048x2048 can be made with no loss of data, however, spatially, the samples will be in the wrong places. This is explained in the next section.

On the Terrapix, scanline 0 contains a 16 bit word containing a 12 bit sample of Green, followed by the same for Red, followed by another Green and so on, 4096 pixels total, containing 2048 Green and 2048 Red pixels. The next line is the same, but first is a Blue pixel, then a Green pixel.

RGB conversion

There are many different ways to interpolate from a Bayer pattern into RGB colorspace.

With a Bayer patterned image, each individual pixel contains either red, green OR blue data, while in an RGB image each individual pixel contains red, green AND blue values.

The problem arises when you try to make an RGB image from the array, by just moving the red, green and blue components around to overlay atop eachother. As you can see from the following example image;

Example showing a line detected in a bayer array

when that line was captured, it was captured with varying red, green and blue samples. This means that if you were to just mush the colored pixels together, for example, one quad (as above) of the bayer pattern becomes one RGB pixel, dropping (or averaging) greens in the quad, you will get anomalous color fringing in the resulting image.

This is, of course, the quickest way to generate the image, but it results in possibly incorrect results.

The common way to do a more accurate result image would be to go for a resulting RGB image the size of the CCD array.

The first step would be to interpolate the green values. By averaging the pixels above, below, to the left, and to the right, you can fill in the missing green data.

The next step is to do the red and blue layers. These require doing a bit more work, since there's less red and blue data. For each, you should also base the brightness of the pixels on the green value in that missing space.

There are a few other tricks that can be done, but I don't have the links to those papers right now.

Links to Bayer-RGB conversion papers

to come soon

-- ScottLawrence - 22 Jun 2004

Topic attachments
I Attachment Action Size Date Who Comment
PNGpng BayerExample.png manage 1.9 K 2004-06-22 - 04:02 ScottLawrence Example of a bayer array
PNGpng BayerLine.png manage 5.1 K 2004-06-22 - 04:04 ScottLawrence Example showing a line detected in a bayer array
PNGpng BayerPattern.png manage 1.5 K 2004-06-22 - 04:03 ScottLawrence A detail of a single bayer quad-pixel
Topic revision: r3 - 2005-06-15 - 21:02:13 - BobKrzaczek
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback