Cameras & sensorsTroubleshooting

Color image too saturated: fix exposure and white balance first

Why a color image comes out too saturated: the histogram test that confirms clipping, the exposure and white balance settings that fix it, with the arithmetic.

LumaSpec Vision12 min read Share on LinkedIn

On this page 10 sections
  1. 01Why does a color machine vision image come out oversaturated?
  2. 02How do you confirm clipping instead of just vivid color?
  3. 03What exposure time should you set to stop the saturation?
  4. 04Should exposure or white balance be fixed first?
  5. 05How do you set white balance so the colors stay put?
  6. 06Why does saturation get worse under the machine's own lights?
  7. 07Could the light controller cause the saturation instead?
  8. 08When is a saturated-looking image not an exposure problem at all?
  9. 09What do you lock in before the line runs?
  10. 10Questions

A color image that arrives looking blown out — reds bleeding to orange, pastels flattened, white parts reading pure 255 — is a bench problem you can fix in ten minutes. The saturation is clipping: at least one of the red, green or blue channels has run out of 8-bit range. This guide gives you the histogram test that confirms it, the exposure arithmetic that ends it, the order in which to set exposure, white balance and light drive, and the settings to log before the line runs. It is written for anyone commissioning a color area scan camera.

Why does a color machine vision image come out oversaturated?

The channels have clipped: one or more of red, green and blue is pinned at 255, so the ratios that carry hue are destroyed, and the usual driver is exposure and white balance left in automatic.

The damage happens after the photons are counted. An 8-bit pixel tops out at 255, and a sensor element that collects more light than that simply reports 255; everything brighter becomes identical. Hue lives in the ratio between the red, green and blue values, so once one channel pins, the color information for that pixel is gone. A pink label turns flat red, a pale yellow turns white.

Automatic modes make this likely rather than rare. Auto exposure aims for a mid-gray scene average, so a small bright part in a dark field gets long exposure times that saturate it. Auto white balance multiplies each channel by its own gain, and those gains reach two to four when a warm 3000 K light meets a sensor calibrated for 6500 K daylight, because the color temperatures differ by a factor of about 2.2 (6500 / 3000). A bright white surface plus a 2× blue boost is exactly how a blue channel clips on a frame that otherwise looks well exposed.

How do you confirm clipping instead of just vivid color?

Hold a plain white diffuse target in the field and read the histogram: a spike of pixels at 255 in any single channel is clipping, while a vivid, correct image peaks below roughly 230 with detail across the range.

Check the channels one at a time. A red component can sit at 255 in red while the gray background reads a comfortable 180, and a combined luminance histogram hides that. Most SDKs expose per-channel statistics or a histogram view; the alternative is to save one raw frame and read the maximum of each plane in code. The histogram exposure metrics for auto exposure and contrast control guide shows the statistics worth logging.

Also check what the numbers are before believing that 255 means clipping. A camera streaming 12-bit data tops out at 4095, and some drivers place those values inside a wider container, which is why a maximum of 65520 can appear in a nominally 16-bit frame. The 12-bit data in a 16-bit V4L2 frame article walks through that case.

What exposure time should you set to stop the saturation?

Scale from one measurement: pixel value grows in proportion to exposure time while the sensor is linear, so if the white patch reads 250 DN at 10,000 µs, the setting that brings it to 200 DN is 8,000 µs.

exposure_new = exposure_old × DN_target / DN_measured blur_px = speed × exposure / pixel_size

Worked example, measured at the bench with gain at its minimum:

  • White PTFE patch at 10,000 µs reads 250 DN. Target 200 DN: 10,000 µs × 200 / 250 = 8,000 µs.
  • Re-measure at 8,000 µs: the patch reads 204 DN, inside the 180-220 band, so exposure is done.
  • 200 DN leaves 55 DN of headroom: a part 25% more reflective than the patch lands at 200 × 1.25 = 250 DN, not at the ceiling.
  • Motion check: a 12 MP sensor 4,000 pixels wide over a 200 mm field gives 200 / 4000 = 0.05 mm per pixel. A belt at 50 mm/s smears 50 × 0.008 = 0.4 mm, which is 0.4 / 0.05 = 8 pixels of blur.
  • If the specification allows 2 pixels of blur, exposure must stay under 2 × 0.05 / 50 = 0.002 s = 2,000 µs. That collects a quarter of the light, so the patch would read 200 / 4 = 50 DN. Recover it at the lens: opening from f/4 to f/2 gains (4 / 2)² = 4×, which puts the patch back at 200 DN with the blur budget intact. If the lens already sits at its widest stop, the answer is more light, not gain.

Two gotchas sit on this step. Some cameras take exposure in µs and some as a fraction of frame time, which is why a valid-looking number gets rejected — see manual exposure value out of bounds: check the exposure unit first. And the value a camera reports can differ from the one you set by a small firmware offset, so trust the DN reading over the logged number; the reported exposure time differs from set exposure article explains that offset. When exposure must stay automatic, cap it below the blur limit, as in cap the maximum auto exposure time to stop motion blur.

Should exposure or white balance be fixed first?

Fix exposure first: white balance is a set of per-channel gains applied after the pixels exist, so on a clipped image it multiplies channels that are already at 255 and cannot pull saturation back.

The order matters because each stage feeds the next. Work down this list and change one thing at a time:

  1. Switch exposure to manual and set it with the arithmetic above.
  2. Switch gain to manual and leave it at its lowest value.
  3. Take a one-shot white balance on the white patch.
  4. Write the three per-channel gains down.
  5. Only now look at any driver-level saturation or gamma control; with the first four done, it usually stays at its default.

Gain deserves the warning. Doubling gain doubles noise along with signal, so it costs image quality for no new information — exposure time or light output collects more photons instead. When a manual setting comes out darker than the automatic one did, the reason is usually that automatic had quietly raised gain; the manual exposure darker than auto exposure: why AE beats your gain article covers that case.

How do you set white balance so the colors stay put?

Take a one-shot white balance on the same white patch you set exposure with, write down the resulting per-channel gains, and run manual from then on: continuous auto white balance re-aims at every frame and shifts hue as parts enter the field.

Let the patch fill roughly a quarter of the frame and run the one-shot; the camera solves the three gains from that single frame and never touches them again. The result follows the light: a typical outcome for a 3000 K warm-white bar on a daylight-calibrated sensor is gains near R 1.0, G 1.2 and B 2.0, while a 6500 K light needs boosts close to 1.0 on all three channels. Treat your own values as properties of the station and record them.

Continuous auto white balance breaks repeatability: it re-aims whenever a bright yellow carton enters the field. The auto white balance drift between frames: use one-shot instead guide shows the failure, and lock auto white balance to a fixed value for repeatable color shows how to hold the solved gains. Stations with several cameras should compare them on one patch before accepting parts, as in the multi-camera white balance consistency: test before rejecting guide.

Menu paths differ by camera family; integrated-camera vendors publish their own configuration walk-throughs, such as this white balance configuration guide for integrated industrial cameras.

Why does saturation get worse under the machine's own lights?

Colored light stacks its energy into one channel: under a red 630 nm bar the red channel clips long before the frame looks bright, while green and blue sit near black, and auto white balance answers by boosting the dark channels into noise.

The fix is spectral, not numerical. Any station that judges color — matching a print, checking a seal's tint, sorting by shade — needs broadband white light, typically 5000-6500 K, so all three channels carry real signal. Colored bars belong on shape and contrast tasks where hue is irrelevant: red light on a green PCB silences the green channel on purpose.

Watch the white as well. Two nominally white lights of different color temperature produce different gain sets, and an LED with a weak blue tail forces large blue gains that amplify noise. If saturation appeared after a light swap under unchanged camera settings, re-run exposure and white balance before touching anything else. The machine vision lights finder filters by color temperature and spectrum so the swap is deliberate, and the lighting topic page collects the matching guides.

Could the light controller cause the saturation instead?

Yes, through brightness and through drive: a light run flat-out can overwhelm any sensible exposure, and dimming that interacts with the exposure window makes brightness jump between frames, so set the light's output at the light controller, not with camera gain.

Three mechanisms matter, and all three live outside the camera. Brightness at the source: if even the minimum exposure time leaves the patch above 240 DN, the light has more output than the sensor can absorb at that f-number, so dim it at the controller. Pulse width: collected light scales with pulse length, so halving the strobe width halves the DN reading, and a pulse four times longer than the light budget needs behaves exactly like 4× overexposure — set the width to the task and lock it. Drive quality: PWM dimming inside the exposure window causes frame-to-frame brightness jumps and banding; the black bars in some camera images: fix lighting flicker vs exposure guide sorts flicker from exposure.

Analog dimming also shifts LED color temperature with current, so a white balance solved at one dim level goes wrong at another. For color work, pick a current, hold it, and solve white balance there. A four-channel constant-current controller sized for 24 V lights is a typical pick:

Light controllersConstant current controller, 4 ch, 120 W, 89 x 147 mm, for 24 V lights (LS-CTL-0180)LS-CTL-0180
Output
Constant current
Channels
4 channels
Control
Digital
Feature
Constant current
$359.00View partBuild a system with it

When is a saturated-looking image not an exposure problem at all?

When the values you are looking at were never 8-bit scene levels to begin with: 12-bit data displayed in a wider container, a wrong pixel format, or a gamma and saturation default in the viewer can each imitate clipping while exposure is already correct.

Work through these in order:

  • Pixel format: a color sensor read out as mono, or a Bayer stream decoded with the wrong pattern, produces wild channel values that look like saturation. Match the format to the sensor path, typically an 8-bit Bayer format for raw color work; the GigE camera shows no color image: fix the pixel format default article is the reference case.
  • Bit depth and container: the 12-bit trap from the histogram section above applies here too — code that assumes full scale stretches or clips wrongly.
  • Auto exposure computing stage: on some drivers the AE loop measures the raw Bayer plane rather than the decoded color image, and its decisions then make no sense for the frames you see; see auto exposure stuck at zero: the Bayer format your driver computes on.
  • Viewer pipeline: gamma, contrast and saturation defaults in the viewing software change what you see, not what the camera sent. Save one raw frame and read the DN in code before turning any knob.

What do you lock in before the line runs?

Freeze five values and log them: exposure time, analog gain, the three white balance gains, strobe width, and the light's drive current or duty, then start every shift by checking the white patch still reads 180-220 of 255.

  • Exposure: manual, value logged, white patch at 180-220 DN.
  • Gain: manual, at the minimum that holds the band.
  • White balance: one-shot gains recorded; mode off, not continuous.
  • Strobe width and delay: fixed numbers, logged with the image batch.
  • Light drive: fixed current or duty at the controller, not adjustable from the cell HMI.
  • Reference check: every shift start, patch mean back in band, or the day's images get flagged.

Any change — a new LED batch, a replacement lens, an added filter — invalidates the white balance gains, so re-run the one-shot and log the new values. Checking settings programmatically before each batch is the subject of the programmatic camera white balance control: verify settings guide.

None of this needs special hardware: any color model with manual exposure, manual gain and per-channel white balance runs the same procedure, for example:

Specification MV-CU020-90GC MV-CS200-10GC MV-CH120-11UC
Sensor type CMOS, global shutter CMOS, rolling shutter CMOS, global shutter
Sensor model GMAX4002 Sony® IMX183 Sony® IMX304
Pixel size 4 μm × 4 μm 2.4 μm × 2.4 μm 3.45 μm × 3.45 μm
Sensor size 1/1.7" 1" 1.1"
Resolution 2048 × 1200 5472 × 3648 4096 × 3000
Max. frame rate 49 fps @ 2048 × 1200 Bayer GB 8 5.9 fps @ 5472 × 3648 30.3 fps @ 4096 × 3000 Bayer RG 8
Dynamic range 66.9 dB 65.5 dB 72.2 dB
SNR 40.8 dB 41.5 dB 40.2 dB
Gain 0 dB to 11.1 dB 0 dB to 24 dB 0 dB to 24 dB
Exposure time 4 μs to 10 sec 46 μs to 2.5 sec UltraShort exposure mode: 1 μs to 14 μs; Standard exposure mode: 15 μs to 10 sec
Exposure mode Off/Once/Continuous exposure mode Off/Once/Continuous exposure auto, supports Timed and Trigger Width exposure mode, and Rolling and Global Reset sensor shutter mode Off/Once/Continuous exposure mode
Pixel format Bayer GB 8/10/10Packed/12/12Packed Mono 8/10/12, Bayer GB 8/10/10p/12/12p, YUV422Packed, YUV422_YUYV_Packed, RGB 8, BGR 8 Mono 8/10/12; Bayer RG 8/10/10Packed/12/12Packed; YUV422Packed, YUV422_YUYV_Packed; RGB 8, BGR 8
Price $309.00 $739.00 $2,339.00 · quoted

All 3 share: Binning Supports 1 × 1, 2 × 2, 4 × 4; Lens mount C-mount; Certification CE, RoHS, KC; Mono/color Color. Values as printed in each product's data sheet; open a part for its drawing and full specifications.

The MV-CU020-90GC covers small fields with a 2.5 MP global-shutter sensor, the MV-CS200-10GC reaches 20 MP over GigE for detail-heavy color scenes, and the MV-CH120-11UC pairs a 12 MP global shutter with USB3 for fast color frames. If the station also needs the light re-sized around the new exposure budget, the camera configurator walks exposure, lens and light together. For help reading a histogram from a specific camera, the contact page reaches the applications team.

Questions

Why does one camera read color correctly and another oversaturate in the same station?

Sensors differ in per-channel sensitivity, and each camera ships with its own default gain map, so identical settings do not transfer between models. Commission each camera against the same white reference in place and record its exposure and per-channel gains separately. When several cameras must match, compare them on one patch and confirm the readings sit within a few DN of each other before trusting either image.

Can clipped channels be recovered in software?

No. A pixel that touched 255 could have been 200 or 245 before clipping, and the original value is gone, so no filter or transform brings the detail back. A histogram with a hard spike at the top of the range is the signature. The only repair is re-acquiring with less light: shorter exposure, lower gain, or a dimmer or shorter-pulsed light.

Does raising gain saturate an image the same way exposure does?

The pixels clip identically, but the cause differs: gain multiplies the signal after readout, so it pushes highlights to 255 without collecting more photons and amplifies noise at the same time. Raise exposure or light output first, and keep gain at the lowest value that holds the white reference inside the 180-220 DN band.

What gray levels should a color inspection aim for across the scene?

Set the white reference at 180-220 of 255, aim mid-tone features near 100-140, and keep the darkest area of interest above roughly 30 so sensor noise stays small next to the signal. That spread leaves headroom above the reference for reflectance swings and LED aging, and enough depth below mid-tone for dark parts to separate from background.

How often should exposure and white balance be re-checked in production?

At commissioning, after any change of light, lens, filter or camera, and whenever the white-patch reading drifts outside 180-220. LEDs dim gradually over tens of thousands of running hours, so a quick check of the patch mean at shift start catches drift before it reaches the classifier. Log the locked values alongside each image batch so a change is visible in the record.