Capturing Accurate Color Through Demosaicing

Capturing Accurate Color Through Demosaicing

Capturing true and accurate color has always been one of the biggest challenges in digital imaging. Since monochrome sensors can only measure the intensity of light and are agnostic to its color, a method was devised to measure the intensity of a specific color of light over each pixel. This method involves placing small filters of alternating color over each pixel using a Bayer pattern.

The Bayer pattern is comprised of alternating red and green filters for every even numbered row of pixels, and alternating green and blue filters for every odd line. Due to the fact that the human eye is most sensitive to green light, half of the sensor is sensitive to this range of wavelengths. It is important to note that other filter patterns, such as the sparse color filter array, also exist, but are far less prevalent than Bayer.

Extracting a full color image from a sensor that only captures 50% of the green light, 25% of the red light, and 25% of the blue light in a scene, represented in a mosaic pattern, can be challenging. The concept that allows for this is known as demosaicing, and it involves evaluating surrounding pixel readings to estimate the two missing colors of the pixel. The simplest approach is a linear interpolation. In the case of a green pixel, you would take the neighboring red pixel values and assign their mean value to the red component of the green pixel, and do so likewise for the neighboring blue pixels (see Figure 1). A more complex approach is to take the average of the red and blue values in a 5 by 5 square surrounding the green pixel to obtain a more accurate depiction of what the red and blue values should be (see Figure 2).


These methods work relatively well but are subject to image artifacts that were not present in the original scene. Some artifacts are visible at the native resolution of the image whereas others are in the finer details of the image and require magnification to become apparent. One of these artifacts is known as false coloring, where colors that were not in the original scene appear due to interpolation errors around the edges of an object, or where there is an abrupt change in color (see Figure 3). A similar artifact to this is the Moiré effect, where a high frequency pattern, such as a striped shirt, develops a new pattern that has twists and curved lines, due to the interpolation method used (see Figure 4). A third artifact, known as zippering, results in the blurring of lines as the demosaicing algorithm averages values around the edges of an object. Once magnified, this effect becomes evident by the staircase or zipper pattern that appears along the edge (see Figure 5).

All Lumenera cameras use a proprietary algorithm that was developed in house by our team of engineers with years of experience in the field of imaging to perform the demosaicing of raw data generated by the color image sensor. Five demosaicing modes can be selected based on the desired speed of the application. When selecting the camera’s higher quality demosaicing algorithm the result will be superior color accuracy and sharpness in the image with no artefacts such as zippering or false colors. This allows Lumenera to produce a wide range of industrial and scientific grade cameras that can produce accurate color representation in images for inspection applications in the machine vision and life sciences industries.