Cameras & sensorsTroubleshooting

RGB IR mosaic decoding artifacts: fix the checkerboard

RGB IR mosaic decoding artifacts trace to a 4×4 tile read as 2×2 Bayer. Fix payload length, unpacking, phase and processor support before white balance.

LumaSpec Vision10 min read Share on LinkedIn

On this page 9 sections
  1. 01What the pattern tells you
  2. 02Capture one controlled baseline
  3. 03Prove the byte layout before touching color
  4. 04Set the mosaic tile and its phase
  5. 05Confirm IR separation and color correction
  6. 06Balance color last, and prove the cast is optical
  7. 07When to change the camera instead
  8. 08Prove the fix and keep the evidence
  9. 09Questions

A yellow-green cast with a checkerboard locked to sensor coordinates is the classic bring-up fault of an RGB IR camera. These sensors repeat their color-and-infrared pattern over a 4 × 4 pixel tile, and somewhere in the chain a component is treating it as a 2 × 2 Bayer tile — or the raw bytes never became samples at all. White balance repairs neither fault. Work the chain in this order: payload length, sample unpacking, mosaic phase, processor support. Touch color controls only after a defocused gray target comes out clean.

What the pattern tells you

A conventional color sensor carries a Bayer mosaic: a 2 × 2 tile with four site classes — 50 % green, 25 % red, 25 % blue. Design guides for RGB IR sensors instead describe a 4 × 4 repeating tile that holds both color and infrared sites: 16 site classes, with the IR sites at fixed positions in the tile. Feed that tile to a component built for 2 × 2, and infrared samples get demosaiced as color on a four-pixel period. The grid survives defocusing the lens, because it is written into the sample interpretation, not the optics.

Count the period before anything else. A Bayer phase error repeats every 2 pixels; an RGB IR tile error repeats every 4. Then place the symptom:

Observation What it points to Test Fix
Payload-length warnings, rows that tear or shift Stride or packing mismatch Compare received bytes with stride × height for the reported format Set the correct format or fix the parser
Raw view looks sound; the color step adds a grid 4 × 4 tile decoded as 2 × 2 Bayer Check the grid period at 1:1 zoom Use the sensor's RGB IR processing path
Grid changes after an ROI crop or a flip Mosaic phase not recomputed Recompute phase from the ROI origin mod 4 Set the phase or restore full frame
Broad cast with no grid Illumination, NIR cross-talk or color settings Gray patch, compare channel means Balance after the decode is clean
Grid appears only in a reduced preview Preview resampling Open the saved frame at native scale Fix the preview path

Scene content that produces false color moves with the target; the guide to false colors and moiré covers that family. A grid that holds still while the target moves is sample interpretation.

Capture one controlled baseline

  1. Aim at a matte gray target under steady illumination, exposed so the brightest samples stay under 972 at 10-bit depth.
  2. Disable auto exposure, auto gain and auto white balance.
  3. Disable crop, mirror, binning and scaling for this capture.
  4. Record 10 frames; every payload must be the same byte length.
  5. Save one raw payload with its metadata — width, height, pixel-format name, bit depth, row stride, ROI origin, payload length — and the processed image from the same frame.

The 972 figure is 95 % of 10-bit full scale:

clipping threshold = 0.95 × (2^10 − 1) = 972

Here 2^10 − 1 is the 1023 full scale of a 10-bit sample, and the 5 % margin leaves headroom for later gain changes. Expect faint repeating structure in the raw view at the tile period — that is the mosaic itself, not a fault; the failure criterion is a grid in the processed output. If your stored file is an encoded image rather than a sample array, work through image bytes versus pixel data first.

Prove the byte layout before touching color

Ten meaningful bits travel packed or in a wide container, and the format name tells you which. GenICam's standard packed formats store four 10-bit samples in 5 bytes (1.25 bytes per sample) and two 12-bit samples in 3 bytes (1.5 bytes per sample); the unpacked Mono10 and BayerRG10 names mean one 16-bit container per sample. Read the buffer exactly as the reported name defines it:

packed row bytes = width / 4 × 5 image bytes = row stride × height

Here width is samples per row, 5 bytes carries each group of four samples, and row stride is the reported bytes per row, padding included. For a 1920 × 1200 frame of packed 10-bit samples:

row bytes = 1920 / 4 × 5 = 2400 bytes image bytes = 2400 × 1200 = 2,880,000 bytes same frame in 16-bit containers = 1920 × 1200 × 2 = 4,608,000 bytes

Both buffers hold the same 2,304,000 samples and need different unpacking; reading either as one byte per pixel produces torn rows, not a darker image. If the camera reports a 2432-byte stride:

image bytes with stride = 2432 × 1200 = 2,918,400 bytes row padding = (2432 − 2400) × 1200 = 38,400 bytes

Read 2400 sample bytes from each row, then advance the full 2432. The 38,400 padding bytes belong to the row, not to an extra image region.

Set the mosaic tile and its phase

The four standard Bayer phases — RGGB, GRBG, GBRG, BGGR — are the only 2 × 2 arrangements, and the standard pixel-format names cover exactly those four. An RGB IR raw stream carries 16 site classes and arrives under a vendor-specific format name. The moment a converter receives one of the standard Bayer names for this stream — set by hand, by a wrapper or by a default — you have your checkerboard, and no phase setting inside that converter removes it. The converter must implement the sensor's 4 × 4 tile.

Get the tile map from the sensor data sheet: tile dimensions, the site class at the frame origin, and the map per operating mode. Compare all 16 classes against your unpacked samples; averaging them into four classes hides exactly the sample mixing that colors the cast.

Cropping and flipping shift the phase. For a 4 × 4 tile:

horizontal phase = ROI x offset mod 4 vertical phase = ROI y offset mod 4

ROI x offset and ROI y offset are the region origin in sensor pixels. A region starting at x = 130, y = 5 sits at phase 130 mod 4 = 2 and 5 mod 4 = 1: two site classes right, one class down from the region corner. Test horizontal and vertical flips separately, and find out where each flip runs, camera or host — the converter needs the layout that actually reaches its input.

Confirm IR separation and color correction

Matching the tile is half the chain. The color sites of an RGB IR sensor still respond to near-infrared; measurements on these sensors show the NIR signal degrading the color channels, and published sensor patents define color correction whose single job is compensating IR contamination of the RGB channels. Reference designs pair the sensor with an external IR illuminator, so the correction has to hold under your illumination. The processing path therefore does three jobs: accept the 4 × 4 tile, separate the IR sites into an IR image, and apply IR-compensating color correction to the color image.

When you request that path, get six answers: the exact raw format and mode it accepts; the tile map and phase convention; whether it outputs IR, color or both; the color-correction data it loads; the firmware and library versions it was validated with; and its behavior on ROI, binning and flips. A function named remosaic only rearranges samples between mosaics — read its description for the IR separation and color-correction steps, which are separate work. Use firmware and libraries from the sensor vendor's own distribution so the version set stays matched.

If no supported path exists for the mode you captured, stop tuning color. Keep the raw frames and request a supported mode or converter; a generic Bayer preview confirms the camera is alive, and nothing more.

Balance color last, and prove the cast is optical

With the decode clean, a broad yellow-green cast has three sources: warm illumination, NIR cross-talk into the color sites, or white-balance state. Capture the neutral gray patch through the pipeline you just validated. As a starting point to confirm on your own target, the three channel means on the patch should land within about 5 % of each other after balance — measure the means, and keep every channel below clipping before applying gains.

Two tests then separate the remaining cast from decode residue. An IR-cut filter, with a cut just above the visible band at around 650 nm on typical vision filters, removes the NIR contribution: if the cast shrinks with the filter in, the cause is spectral. Rotate the camera 90° relative to the target with processing untouched: a grid that rotates with the sensor is sample interpretation; structure that rotates with the target is target texture.

Keep the controls separate with the image-quality settings guide, and read back what the camera actually applied with programmatic white-balance checks.

When to change the camera instead

One decision splits the road: does the station need a co-registered infrared channel, or only visible color? Occupancy sensing, driver monitoring and NIR-based material sorting need the IR channel — keep the RGB IR sensor and finish its processing path. Color-only inspection is simpler on a conventional Bayer camera: the tile is 2 × 2, the camera reports one of the four standard phases, and every GenICam decoder handles it.

For a color-only station, the MV-CU020-90GC is the fit: 2.5 MP global-shutter color on GigE, a 1/1.7" sensor and a C-mount.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

When the part needs more pixels, the MV-CH120-11UC carries 12 MP global-shutter color on USB3 with a 1.1" sensor and the same C-mount.

Area scan camerasHikrobot MV-CH120-11UC 12 MP Area Scan Camera, USB3, IMX304, High-speed version, ColorMV-CH120-11UC
Sensor format
1.1"
Lens mount
C-mount
Interface
USB3
Resolution
12 MP
$2,339.00 · quotedView and quoteBuild a system with it

Browse area scan cameras and the camera finder to narrow interface, shutter and mount, then run the camera configurator once pixel count and field of view are set. Changing interface or shutter never repairs an unsupported decoder; that fix belongs to the software path.

CamerasArea scan cameras

GigE, USB3, 10GigE and CoaXPress

1,287 models · from $149.00

Prove the fix and keep the evidence

A correction holds when it survives more than one target and more than one frame:

  • Payload integrity: received bytes equal stride × height for the reported format, across all 10 baseline frames.
  • Unpacked samples: value range and row boundaries identical across repeated captures.
  • Mosaic identity: the processor loads the sensor's 4 × 4 tile by name, not a Bayer phase.
  • Spatial output: a defocused gray target shows no four-pixel grid at 1:1 zoom.
  • Transforms: recompute ROI phase (offset mod 4) after every crop change; flips pass through one at a time.
  • Color response: channel means on the neutral patch inside the 5 % starting-point band, nothing clipped.
  • Restart: the saved configuration reproduces the same output after a power cycle.

Keep raw payloads, metadata and processed references together as one set; that set is what separates a later software regression from a lighting change. If a grid survives clean layout and phase, send the set through the sensor vendor's support channel with the smallest configuration that reproduces it. To plan a replacement acquisition chain, contact the applications team with the visible and infrared outputs the station must deliver.

Questions

Can white balance remove a checkerboard from RGB IR images?

No. White balance scales channels after samples are assigned to color sites. A 4 × 4 RGB IR tile misread as 2 × 2 leaves infrared samples inside the color image on a four-pixel period, and gains only recolor that grid. Clear the payload length, unpacking, phase and processor support first, then balance a neutral gray patch with every channel below clipping — at 10-bit depth, keep peaks under 972.

Does a repeating pattern in the raw view always mean decoding is wrong?

Not always. A raw monochrome view of a uniform target shows the mosaic itself: 16 position classes on a 4 × 4 period, each with its own sensitivity, so faint repeating structure is correct behavior. The failure criterion is a grid in the processed color output. Compare unpacked samples against the tile map in the sensor data sheet instead of judging raw-view smoothness.

Why do all ordinary Bayer conversion options still produce artifacts?

Standard GenICam pixel formats define the four 2 × 2 Bayer phases — RGGB, GRBG, GBRG, BGGR — with four site classes each. An RGB IR sensor repeats over 4 × 4 with 16 classes and streams under a vendor-specific format name. Cycling the four phases only relabels sites; it never performs the infrared separation and color correction the tile needs. Use the sensor vendor's RGB IR processing path.

Should an infrared-blocking filter be the first purchase?

Not first. A cut filter around 650 nm removes the near-infrared contribution that lifts red and yellows the cast, which makes it a good test once the decode is clean — but it leaves a sample-interpretation grid untouched. Order the work: layout, phase, processor support, then the filter decision. If the station needs the IR channel for its measurement, a blocking filter removes that channel; keep the RGB IR sensor and finish its software path.

What evidence should accompany a support request?

Send one raw payload plus its metadata: width, height, pixel-format name, bit depth, row stride, ROI origin and reported payload length — for a 1920 × 1200 packed 10-bit frame, 2,880,000 bytes before stride padding. Add the processed image from the same frame, the software, firmware and library versions, and the smallest configuration that reproduces the grid. A neutral-target capture of both outputs shortens the round trip.

Corrections

  • Rewritten for usefulness: specific values with their basis, the named standards, a worked example, no hedging.