Basic color processing

That a digital camera is able to capture color images is normally nothing worth mentioning. But the color processing in the camera is a very complex topic and nothing trivial.

What the manufactures do in the very detail is covered up in silence, but the basic concept is always the same:


1.  RAW

The vast majority of color image sensors use a bayer pattern of red, green and blue filter to make it a color sensor. So each pixel is just able to detect one color, it “sees” red, green or blue. As green is the most important color for the luminance information, we have two green pixel for one blue and one red pixel.

raw
The sensor signal does not contain color information, each pixel just represents one color.

mosaiced
Detail of the image above. Each pixel just detects one color. The image is still “mosaiced”.

 


2.  DEMOSAICING

To get the red, green and blue information per pixel, the important step of “demosaicing” interpolates the missing information. This is a very vital part of image quality and therefore a well kept secret of every manufacturer what they do in detail. As the different filter results in a different sensitivity to light and a low signal strength, the noise level can be very different. In the demosaicing process, the noise is spread over the neighbors, the noise in the different color channels is correlated to each other.

bayer
The information of one pixel is used for the color information in the neighboring pixel. This also spreads the noise.


demosaicing
After the demosaicing, each pixel has a value for red, green and blue, so it becomes a color image.

 


3.  WHITE BALANCE

The sensitivity of the different color channels can be very different in a digital camera. To get correct colors as they appear to the human visual system, the camera to control the gain of the different channels differently. After white balancing, neutral areas in the image appear neutral and have nearly the same digital value for red, green and blue.

white balance
After the gain of all channels have been adjusted, the image appears neutral.

 


4.  COLOR CORRECTION MATRIX (CCM)

Each camera has an individual spectral sensitivity. So the RGB output of a camera is specific to that camera. To get consistent results for all cameras, this RGB_camera has to be transformed into a defined and know colorspace. In most cases this is sRGB, but it can be any other colorspace. To transform the values from RGB_camera to e.g. sRGB, one has to apply a 3x3 color correction matrix (CCM) to the data.*

color space
After applying the CCM, the colors are in a defined colorspace (here: sRGB).


*The spectral sensitivity of the camera is the basis for the CCM. A fast and highly accurate way to get this is offered bycamSPECS express


5.  GAMMA

Until now, the image data is still linear. So doubling the light intensity will double the digital value in the image, not matter if checked in the dark areas or in the bright areas if the image. To get a correct representation on output devices, images normally have a gamma function applied. This tonal curve is applied to the image at the end of image processing, as from now on the image data is non-linear.

gamma
Done, now we have a transformed a raw image to a sRGB image.

ua