Lookup Table Operations

A lookup table (LUT) is a precomputed mapping that replaces pixel-by-pixel calculations with simple array indexing. Each possible input value (0–255 for standard 8-bit channels) maps directly to its transformed output value. Rather than computing the same transformation formula for every pixel, the LUT computes it once during initialization. This approach is significantly faster, especially when applying the same transformation to multiple images, while producing mathematically identical results to the equivalent direct computation.

LUT for Color Balance

A color image can be corrected by adjusting gamma and white balance.

These effects can be corrected efficiently by setting up a lookup table using EColorLookup::WhiteBalance .NET Python and applying it to a series of images by means of EasyColor::Transform .NET Python. The LUT only needs to be prepared once, enabling efficient reuse across multiple images.

Gamma Precompensation

  • Many color cameras use a gamma precompensation process that deals with the non-linear response of the display device (such as a TV monitor).

  • Gamma precompensation should be used after processing because using it before would change the result because of the nonlinearity introduced.

  • The precompensation process applies the inverse transform to the signal, so that the image renders correctly on the display. Three predefined gamma values are available, depending on the video standard at hand:

Video standard

Gamma value

EasyColor property

NTSC

1/2.2

EasyColor::GetCompensateNtscGamma .NET Python

PAL

1/2.8

EasyColor::GetCompensatePalGamma .NET Python

SMPTE

0.45

EasyColor::GetCompensateSmpteGamma .NET Python

Note

Precompensation cancellation and pure precompensation correspond to exponents that are inverse of each other.

Gamma Precompensation Cancellation

  • Many color cameras have a built-in gamma precompensation feature that can be turned off. If this feature cannot be turned off and is not desired, its effect can be canceled by applying the direct gamma transform. The following predefined gamma values are available for this purpose:

Video standard

Gamma value

EasyColor property

NTSC

2.2

EasyColor::GetNtscGamma .NET Python

PAL

2.8

EasyColor::GetPalGamma .NET Python

SMPTE

1/0.45

EasyColor::GetSmpteGamma .NET Python

White Balance

  • A camera may exhibit color imbalance, that is, the three color channels having mismatched gains, or the illuminant (the light sources) not being perfectly white. When this occurs, the white areas appear as an unsaturated color.

  • The white balance correction automatically adjusts three independent gains so that the components of a white pixel become equal. This means that a white balance calibration step is required, during which a white surface must be shown to the camera and the corresponding color components are measured. EImageStatisticsBW8::GetPixelAverage .NET .NET can be used for this purpose.

Input image.
White balance and gamma precompensation.

LUT for Color Calibration

  • Color distortions introduced by the image acquisition chain can be corrected by comparing sample colors from the image with their true values. A calibrated color chart, such as the IT8, is required.

    • Sample colors are the average color in a suitable ROI using EImageStatisticsBW8::GetPixelAverage .NET .NET.

    • True color values are specified in the XYZ color system. Even though the reference colors are described by their XYZ coordinates, the image to be calibrated must contain RGB information.

  • The calibration transform can be based on one, three, or four reference colors. In the first case, calibration is a gain adjustment for the three color components. In the second and third cases, a linear or affine transform is used.

LUT for Gain / Offset (Color)

Separate gains and offsets can be applied to each of the three components of an image (contrast enhancement transform). The RGB image must be transformed to the targeted color space, gains and offsets applied, then transformed back to RGB.

  • When applied to a mixture representation, all three gains and offsets should vary in a similar way.

  • When applied to luma / chroma representations, the gain and offset of the chromatic components should vary in a similar way.

  • When applied to intensity / saturation / hue representation, it makes no sense to apply gain and offset to the hue component.

Input image.
Gain and offset adjustment.

Note

The contrast enhancement function can be used to make a given component uniform: setting the gain to 0 for some component has the same result as setting all pixels to the value of the offset for this component.