Bayer Demosaicing

From Redhax

Jump to: navigation, search
Most digital sensors are monochrome, meaning each light detecting pixel does not have the ability to discern multiple channels of color. Many video cameras determine color using three seperate image sensors. Light entering these cameras is split into three directions using a series of prisms and filters such that red, green, and blue light selectively reaches each sensor.

Digital cinema cameras use one single large sensor and must use a different technique to determine the color of each pixel. There are exceptions but for the most part these cameras use a technique called a Bayer filter.

The smallest component of a Bayer pattern is 4x4 pixels
The smallest component of a Bayer pattern is 4x4 pixels
A Bayer filter selectively blocks certain wavelengths of light before reaching the sensor so that each pixel is sensitive to either red, green or blue light. These selective color filters are arranged in a pattern called a 'Bayer pattern' which allows a computer to later guess the value of the two blocked colors of a pixel based on the value of its neighbors. This process of educated guessing is refered to as demosaicing, bayer interpolation, or debayering. Images that are recorded as a Bayer pattern are sometimes called raw.

In addition to being a solution to the single chip color problem a Bayer pattern is also considered a kind of natural image compression. Since each pixel contains only one color channel a Bayer pattern image is exactly one third the size of its three channel RGB equivalent.

Contents

[edit] How Demosaicing Works

Digital Images are often represented as RGB. In an RGB image each pixel is represented by three values that determine the intensity of light in the red, green, and blue parts of the spectrum. In order to display a Bayer pattern image or manipulate it must first be converted to RGB. In order to do this a computer can use one of many different strategies to fill in the blanks for each pixel. These strategies are demosaicing algorythms.

[edit] Linear Interpolation

Bilinear interpolation is a simple example of a demosaicing algorithm that can be used to help explain the process.

As seen in the diagram the pixel G5 does not have green information. It is possible to give the pixel a green value by averaging the neighboring pixels. So:

  • G5 = (G2 + G4 + G6 + G8)/4

The pixels missing their red information can be calculated in a similar way:

  • R2 = (R1 + R3)/2
  • R4 = (R1 + R7)/2
  • R5 = (R1 + R3 + R7 + R9)/4

The pixels missing their blue information can be calculated in a similar fashion.

In practice this algorithm is too simple, not sharp, and introduces many color artifacts. In practice bilinear interpolation is never used.

[edit] Hue As A Predictor of Intensity

One of the main problems with the Bilinear interpolation method is that it treats each color channel completely separately from one another. In fact it is possible to take clues from neighboring pixels even though they represent different color channels. This is possible because the hues in a natural image usually change much less rapidly than the corresponding luminance.

In an RGB image hue is determined by the ratio between all three color channels for a given pixel. Because the hue of two neighboring pixels is likely to be similar it is possible to predict the value of the missing color channels if the ratio is known.

Because the green channel of a Bayer image contains twice the samples of the red and blue channels, an algorithm can start by interpolating the green channel independently. Once this is done ratios between blue and red and green and red can be used to calculate more accurate values for all pixels.

[edit] More Complicated Algorithms

Using hue ratios is just the beginning of the possible methods for creating accurate and eye pleasing RGB images from a Bayer Pattern source. Complex algorithms use known properties of natural images and other tricks to create sharp and accurately colored images. Some of these algorithms are documented while others are proprietary.

While the differences between the algorithms is often very subtle, it is the case that their results vary depending on the content of the source image. In most cases a standard high quality algorithm will work well, in other cases one might want to choose the appropriate algorithm for their specific content.

[edit] Available Algorithms and Their Suggested Subject Matter

Hoping for more information on this soon.

[edit] How Much Resolution Does A Bayer Filter Sensor Have?

The Bayer filter technique works well because it exploits a common trait of most natural images: hue changes more gradually than intensity. Even though each pixel does not contain all color information, the single channel it does contain is an excellent predictor of the overall intensity of the image at that point.

The human eye exploits the same phenomenon: The eye contains many more intensity resolving rods than color differentiating cones, making it much better at resolving changes in intensity than color. When a Bayer pattern is demosaiced with a very effective algorithm the overall detail in the intensity of the image will come close to the original. Many would say that a Bayer chip produces upto 70% of it's native resolution .

For this reason it is not correct to say that a Bayer filter reduces the effective resolution of an image. It is more accurate to say that the system is not as accurate as an RGB equivalent would be but that it comes close in terms of the perception of sharpness and detail.

[edit] Software

[edit] REDCODE Quicktime Component

Does it perform debayering? If so is it possible to select which algorythm is used?

[edit] REDCine

What options does it give you in terms of debayering?

[edit] Further Reading

[edit] Scientific Papers

Personal tools