Skip to main content
Designer and manufacturer of advanced imaging equipment
Thursday, 15 October 2026

Article

Color correction matrix and its calculator with a color chart in ALTRON

rahni

One of the common complaints in packaging inspection is this: “White is right, gray is right, but the red of the logo comes out slightly orange in the image.” Here white balance no longer helps. What you need is The color correction matrix.. In this article we explain how to build it with a color chart and the ALTRON calculator and apply it to a color area-scan camera.

Why isn't white balance enough?

White balance only changes the gain of each channel separately so that neutral colors become neutral. But the color filters on the sensor are not exactly like the human eye. Part of the red light leaks into the green channel and part of the green into the blue. As a result, saturated colors, like that red of the logo, look slightly shifted.

The color correction matrix (CCM) compensates for this leakage. Each output channel is built from a combination of all three input channels, and a constant offset is added to it. That means twelve numbers: three coefficients and one offset for each channel.

Step one: a proper photo of the color chart

  • Place the standard 24-patch color chart under the same light you have on the production line.
  • Before taking the photo, set the white balance correctly. The matrix does not replace white balance.
  • Set the exposure so that the white patch of the chart is not saturated.

Step two: calculating the matrix with the calculator

Open the Color Correction Calculator tool from the Tools menu:

  1. Open the chart photo with Open Image.
  2. Press Align to Chart (4 pts) and click the four corner patches in this order: top-left, top-right, bottom-right and bottom-left. All 24 patches snap into place. If the chart is mirrored in the image, press Mirror Horizontal or Mirror Vertical.
  3. Press Extract from Color Checker. For each patch you see the observed color (Seen) and the expected color (Expected). The Weight column sets the importance of each patch in the calculation.
  4. Choose a model and press Calculate.
  5. Copy the twelve numbers with Copy Results.

Which model?

  • 3×3 – linear light (Basler): first linearizes the color and then applies the matrix. White stays correct and there is no overfitting. It is a good starting point.
  • 3x4 models: also have an offset, which helps dark colors and shadows.
  • Polynomial deg-2: gives the lowest error on the chart patches, but may overshoot the target on extreme colors such as white.

Step three: applying the matrix in the graph

In the graph editor, add the ColorCorrectionMatrix node after the Debayer node, because this node works on the RGB image. Then:

  1. In the node panel, turn on Enable.
  2. Press the Paste button so that the twelve copied numbers are placed into the matrix. If there are not exactly twelve numbers, the matrix does not change.
  3. To compare before and after, press Identity. The image passes through unchanged. Then load the matrix again.

The Use Lookup Table option is on from the start; leave it on. Instead of computing the matrix for every pixel, it uses a precomputed table and is much faster at high frame rates.

One matrix per product

If different products are inspected under different lighting, build a separate matrix for each one. In the Preset Edit section, type a name and press Add. Update refreshes that same preset. When the product changes, simply select the appropriate matrix from the list.

When a matrix is not enough

If your color relationship is more complex than a single matrix, press Export Color Correction Template in the calculator. A file with the .cct extension is created. Load it into the ColorCorrectionTemplate node. This node is already present in the preset graph for the color area-scan camera. Each template is valid for only one pixel format.

If you have a line scan color camera, this template is the way to go. The ColorCorrectionMatrix node is only for area-scan cameras, but ColorCorrectionTemplate also works on line-scan cameras.

Common mistakes

  • Photographing the card under lighting other than the production line’s. The matrix is only correct for the lighting it was computed with.
  • Saturated patches. If the white patch has hit the ceiling, its information is lost.
  • Computing the matrix before white balance. Fix the white first, then compute the matrix.

If you want to read more about the theory behind the ColorChecker chart, see this Wikipedia article (English) is a good start.

See the colour models on the area scan cameras page. If you need help building a color matrix, let us know via contact page.

Where our equipment is used

Organizations, universities, industries and companies that have used our products

  • Hedayat Hooshmand Nozhan Sepehr