Color Space Conversion and Correction - 2.4 English

Video Processing Subsystem Product Guide (PG231)

Document ID
Release Date
2.4 English

There are many variations that cause difficulties in accurately reproducing color in imaging systems. These can include:

  • Spectral characteristics of the optics (lens, filters)
  • Lighting source variations like daylight, fluorescent, or tungsten
  • Characteristics of the color filters of the sensor

The Color Space Converter/Correction function provides a method for correcting the image data for these variations. This fundamental block operates on either YUV or RGB data.

As an example, following one of the three color channels through an imaging system from the original light source to the processed image helps understand the functionality of this core.

The blue color channel is a combination of the blue photons from the scene, multiplied by the relative response of the blue filter, multiplied by the relative response of the silicon to blue photons. However, the filter and silicon responses might be quite different from the response of the human eye, so blue to the sensor is quite different from blue to a human being.

This difference can be corrected and made to more closely match the blue that is acceptable to human vision. The Color Space Converter/Correction function multiplies the pixel values by some coefficient to strengthen or weaken it, creating an effective gain. At the same time a mixture of green or red can be added to the blue channel. To express this processing mathematically, the new blue (Bc) is related to the old blue (B), red (R), and green (G) according to:

Figure 1. D 3.615000000000002 B c = K 1 × R × K 2 × G + K 3 × B

where K1, K2, and K3 are the weights for each of the mix of red, green, and blue to the new blue.

Extending this concept, a standard 3 x 3 matrix multiplication can be applied to each of the color channels in parallel simultaneously. This is a matrix operation where the weights define a color-correction matrix. In typical applications, color-correction also contains offset compensation to ensure black [0,0,0] levels are achieved. The following matrix operations can also be used for color correction:

Figure 2. E 27.104100000000003 R C G C B C = K 11 K 12 K 13 K 21 K 22 K 23 K 31 K 32 K 33   R G B   +   O 1 O 2 O 3
Figure 3. F 27.104100000000003 Y U V = K 11 K 12 K 13 K 21 K 22 K 23 K 31 K 32 K 33   Y U V   +   O 1 O 2 O 3
Note: The K coefficients are presented in S3.12 fixed point format (1 sign bit, 3 integer bits, 12 fractional bits). The 16-bit signed integer values (2’s compliment) are equivalent to real numbers in the [-8 .. 8] range. The offset values O have a width of the data width plus 1. It is a signed integer with a range of [-2Data_Width, 2Data_Width-1].
Matrix Operation
The 3x3 Matrix (and offsets) can be used to perform color space conversion between RGB and YUV 4:4:4:
Figure 4. G 27.104100000000003 R G B = K 11 K 12 K 13 K 21 K 22 K 23 K 31 K 32 K 33   U Y V   +   O 1 O 2 O 3
Figure 5. H 27.104100000000003 U Y V = K 11 K 12 K 13 K 21 K 22 K 23 K 31 K 32 K 33   R G B   +   O 1 O 2 O 3
As shown in the matrix operation, the input pixels are transformed to a set of corrected output pixels. This can be a very useful function configured as a static application; however, the programmability of the coefficients and offset values allows this function to adapt to changing lighting conditions based on a separate control loop.
Clipping and Clamping
The Clip and Clamp values have the same width as the data width. They are unsigned integers with a range of [0, 2Data_Width-1].