ApplicationsGuide

Machine vision colour inspection beyond raw RGB values

Build repeatable machine vision colour inspection with fixed lighting, reference samples and validated limits, then choose hue or colour difference.

LumaSpec Vision11 min read Share on LinkedIn

On this page 11 sections
  1. 011. Define the colour decision before selecting hardware
  2. 022. Stabilize the illumination and reflection geometry
  3. 033. Select a colour camera and budget enough useful pixels
  4. 044. Fix the acquisition pipeline before setting thresholds
  5. 055. Choose the metric that matches the acceptance question
  6. 066. Work through a shade-acceptance example
  7. 077. Build reference samples and validate the complete decision
  8. 088. Keep motion and part tracking separate from colour accuracy
  9. 099. Know when a camera is not the reference instrument
  10. 1010. Check the specification before ordering
  11. 11Questions

Machine vision colour inspection works when the imaging conditions are repeatable and the acceptance rule matches the task. Start by deciding whether you need to separate visibly different colours or measure a small shade difference against an approved reference. A colour camera can support either task, but neither starts with an arbitrary RGB threshold. This guide explains how to control illumination, select acquisition settings, choose a colour metric and validate the decision before ordering a complete station.

1. Define the colour decision before selecting hardware

Write the requirement as a production decision, not simply “check colour.” A system separating red and blue components has different needs from one accepting small shade changes in a painted surface.

Define these items first:

  • Classes or tolerance: identify named colour families, or define an allowed difference from a reference.
  • Inspection region: specify the surface area that actually represents the part colour.
  • Surface condition: distinguish matte, glossy, textured, translucent and metallic finishes.
  • Operating range: include permitted position, orientation, speed and material variation.
  • Error consequences: state what a false acceptance and a false rejection cost the process.

For broad classification, a hue-and-saturation rule may be sufficient. For shade acceptance, use controlled acquisition, suitable colour calibration and a validated difference metric. For a specification tied to standardized colour measurement, establish an instrument-based reference method first.

Our guide to comparing colour between images with meaningful metrics explains the measurement choices in more detail. The aim here is to turn those choices into a repeatable inspection station.

2. Stabilize the illumination and reflection geometry

The camera records light reflected or transmitted by the object, not an intrinsic colour label. Changing the illumination spectrum, viewing angle or surface reflection can change the recorded colour without changing the material.

Use white illumination with documented spectral characteristics suitable for the task. Keep the illumination geometry, output setting and camera position fixed. Allow the light to reach a repeatable operating condition, then measure drift rather than assuming a particular warm-up period.

For curved or glossy parts, dome lights can reduce localized reflections by illuminating from many directions. They do not remove every reflection, and the camera opening can remain visible on highly reflective surfaces.

How a dome light works LEDs at the rim light the white inner surface of the dome, which lights the part evenly from almost every direction. The camera looks through a hole at the top; on flat mirror-like areas the hole reflects as a dark spot.Cameradiffuse inner surfacelights the part from every sideLED ringcamera holecurved or wrinkled part; dark spot where the hole reflects
How a dome light works. LEDs at the rim light the white inner surface of the dome, which lights the part evenly from almost every direction. The camera looks through a hole at the top; on flat mirror-like areas the hole reflects as a dark spot.

Review LS-DOM-0062 as a diffuse-lighting candidate. Confirm the supplied colour variant, usable opening and mechanical clearance before selecting it for colour measurement.

Dome lights3.0 dome light, outer diameter 194 mm (LS-DOM-0062)LS-DOM-0062
Size
100-200 mm
Voltage
24 V
$819.00View partBuild a system with it

Outer dimensions alone do not establish how large a part can be illuminated consistently. The guide to dome lights for shiny, curved and wrinkled parts explains the geometric checks. Use the lighting finder to compare physical arrangements after establishing the required field coverage.

Do not choose an illumination colour solely because it makes a defect conspicuous. Narrowband illumination can improve feature contrast while removing information needed to distinguish material colours. The guide to LED colour selection for machine-vision contrast addresses that separate objective.

3. Select a colour camera and budget enough useful pixels

Choose area scan cameras by the required field of view, smallest usable colour region, motion and acquisition interface. Pixel count alone does not establish colour accuracy.

For moving parts, a global shutter is usually the simpler starting point because it avoids row-dependent exposure timing. A rolling shutter can be suitable when the part is stationary throughout acquisition. Neither shutter type removes motion blur from an exposure that is too long.

MV-CU020-90GC is a colour camera with a global shutter. MV-CS200-10GC is a colour camera with a rolling shutter. These are acquisition candidates, not claims of calibrated colour performance.

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
$309.00View part
Area scan camerasHikrobot MV-CS200-10GC 20 MP Area Scan Camera, GigE, IMX183, Color, BasicMV-CS200-10GC
Sensor format
1"
Lens mount
C-mount
$739.00View part

Estimate the required horizontal pixel count from the narrowest region you must measure:

Required horizontal pixels = field width × pixels across region / region width

Suppose the field width is 100 mm and the narrowest usable colour region is 0.50 mm wide. An initial sampling target of 8 pixels across that region gives:

Required horizontal pixels = 100 × 8 / 0.50 = 1600 pixels With 20% sampling margin: 1600 × 1.20 = 1920 pixels

This is a sampling example, not a universal colour-measurement requirement. Lens blur, demosaicing, texture and boundary exclusion can require more pixels. A larger interior region generally gives a more stable average than a narrow strip beside an edge.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

Use the camera finder to shortlist the acquisition hardware. Then verify lens coverage, working distance and image quality using actual part images. Do not assume that additional pixels compensate for glare or an unstable light source.

4. Fix the acquisition pipeline before setting thresholds

Automatic settings can make an image look consistent while moving its numerical colour values. Establish the image pipeline before collecting acceptance data.

  1. Set exposure using the brightest acceptable sample and check every colour channel for clipping.
  2. Use the lowest practical gain consistent with the exposure and signal requirements.
  3. Establish white balance under the production illumination, then hold it fixed during inspection.
  4. Fix gamma, colour correction, sharpening and other processing settings that affect the measurement.
  5. Record the pixel format, bit depth, software conversion and camera settings with the inspection recipe.
  6. Repeat these checks after a camera, light, lens or software change.

A neutral target helps set channel balance. It does not, by itself, characterize the response to all material colours. Colour calibration needs suitable reference patches spanning the range you intend to measure.

The article on which pixels influence automatic exposure and gain explains why the selected image region matters. For a fixed inspection station, uncontrolled adaptation should not silently change the acceptance basis.

Use light controllers to maintain a documented operating setting. LS-CTL-0290 is a digital constant-voltage controller candidate. Verify electrical compatibility rather than assuming that a shared nominal voltage makes a complete pairing.

Light controllersDigital constant-voltage light controller, 60 W, 4 channels (LS-CTL-0290)LS-CTL-0290
Output
Constant voltage 24 V
Channels
4 channels
Control
Digital
$449.00View partBuild a system with it

The light-controller finder helps narrow the output type and channel requirements. Confirm light demand, channel limits, connectors and any trigger functions from the applicable documentation.

5. Choose the metric that matches the acceptance question

Changing colour space does not remove the need for stable acquisition. It changes how the recorded information is represented and compared.

Method Suitable starting point Main limitation Validation check
RGB ranges or channel ratios Widely separated classes in a fixed setup Sensitive to illumination, clipping and camera processing Test all permitted shade and brightness variations
Hue with saturation limits Distinct colour families Hue becomes unstable near neutral colours or very low signal Reject or separately handle low-saturation regions
Colour histogram or pixel proportions Mixed-colour regions or variable coverage Can hide spatial defects and small unwanted patches Check both distribution and defect location
Profiled CIELAB colour difference Shade comparison against approved references Depends on calibration, reference conditions and metric choice Compare with the agreed reference measurement

Hue is circular. Values near the two ends of its numeric range can describe almost the same hue. Use circular distance or a range that wraps correctly, not an ordinary subtraction across the boundary.

For CIELAB, a simple distance is the Euclidean difference commonly called ΔE76:

ΔE76 = sqrt[(L*sample − L*reference)^2 + (a*sample − a*reference)^2 + (b*sample − b*reference)^2]

This formula is easy to audit, but equal distances do not correspond equally well to perceived differences throughout colour space. More advanced colour-difference formulas address some of those limitations. Their thresholds are not interchangeable.

Do not convert arbitrary camera RGB values to CIELAB and immediately label the output a standardized measurement. The conversion must account for the input encoding, camera response, profiling and reference white. A generic display-colour conversion may support a local classifier, but it does not establish instrument agreement.

6. Work through a shade-acceptance example

Consider an illustrative calibrated workflow with a reference value of L* = 50, a* = 12 and b* = 18. A measured sample gives L* = 52, a* = 13 and b* = 19.

ΔL* = 52 − 50 = 2 Δa* = 13 − 12 = 1 Δb* = 19 − 18 = 1 ΔE76 = sqrt(2^2 + 1^2 + 1^2) = sqrt(6) ≈ 2.45

If an agreed application tolerance were 3.0 using this exact metric, the measured difference would fall below it. That alone does not establish a dependable acceptance decision.

Suppose a validated measurement study supports an uncertainty allowance of 0.8 for this decision. A conservative guard-band rule might require the measured difference plus that allowance to remain within tolerance:

Acceptance rule: measured difference + allowance ≤ tolerance Example: 2.45 + 0.8 = 3.25 3.25 > 3.0, so do not automatically accept

The tolerance and allowance here are illustrative, not recommended industry limits. Establish both from the product requirement, reference method and measurement study. Define what happens in the borderline region: remeasure, route for instrument inspection or hold for review.

Also inspect the region itself. An average can conceal a small discoloured patch surrounded by acceptable material. Combine an overall shade metric with a local-area rule when spot defects matter.

7. Build reference samples and validate the complete decision

An approved reference should represent the actual material and finish. A printed colour chart can characterize the imaging pipeline, but it does not replace production samples with relevant gloss, texture or translucency.

Include acceptable extremes, clear rejects and difficult borderline samples. Keep a separate validation set that was not used to choose thresholds. Otherwise, tuning can produce an apparently strong classifier that fails on unfamiliar production variation.

As an initial study design, consider 30 representative parts captured 10 times each, giving 300 observations. Reposition the parts between captures. This reveals more than repeatedly imaging an untouched sample, but it is not automatically enough to demonstrate a required defect escape rate.

Separate these effects:

  • Short-term repeatability: repeated captures under unchanged conditions.
  • Repositioning variation: the same part presented at permitted locations and angles.
  • Operating drift: changes across production time and documented operating conditions.
  • Part variation: genuine differences among acceptable material batches and finishes.
  • Reference agreement: consistency with the approved measurement method.

Validate the final pass/fail rule, not just the spread of a colour coordinate. Count false acceptances and false rejections by defect type. A low average error can hide poor performance on the most consequential defect.

Keep references protected from handling damage and material aging. Define a replacement and verification process rather than treating one physical sample as permanent truth.

8. Keep motion and part tracking separate from colour accuracy

A correct colour decision is useless if it is assigned to the wrong part. Record the relationship between the trigger, acquired image, decision and downstream action.

For motion blur, estimate the distance travelled during exposure:

Object motion during exposure = object speed × exposure time

At 500 mm/s with an exposure of 0.20 ms:

Motion = 500 × 0.00020 = 0.10 mm At 0.05 mm/pixel: blur = 0.10 / 0.05 = 2 pixels

That blur can mix neighbouring colours at an edge. Shorten exposure, improve usable illumination or measure farther inside the region. The guide to exposure time for moving-part inspection explains the motion budget.

If pulsed lighting is needed, verify documented pulse timing, output limits and duty cycle for the actual light-controller combination. Do not infer pulse capability from digital brightness control. The guide to strobe timing and duty cycle covers those checks.

During commissioning, test missing images, delayed decisions and consecutive rejected parts. The machine controls must handle those conditions through the appropriate machine design; a colour classifier is not a safety function.

9. Know when a camera is not the reference instrument

Use a spectrophotometer or another agreed instrument when the acceptance specification requires standardized colour measurement, tight inter-site agreement or spectral information that a camera does not provide.

Different reflectance spectra can produce similar camera channel responses under one light but differ under another. A coordinate conversion cannot recover spectral information that the camera never captured. A spectrophotometer can provide spectral reflectance data, although its measurement geometry and reference conditions still need to match the requirement.

Metallic, pearlescent, fluorescent and translucent materials need particular care. Viewing angle, illumination spectrum, backing and material thickness can change the measurement. A single camera view may not capture the specified appearance attribute.

A practical division of work is to establish material acceptance with the agreed instrument and validate the inline camera against representative production samples. The camera then performs the qualified production decision, rather than claiming to replace every capability of the reference instrument.

10. Check the specification before ordering

Use this checklist to turn an imaging concept into a purchasing requirement:

  • Decision: document colour classes, shade tolerance or both.
  • Reference method: identify the approved samples, metric and measurement conditions.
  • Optics: confirm field coverage and enough usable pixels away from boundaries.
  • Illumination: specify the white variant, geometry, stability checks and ambient-light contribution.
  • Acquisition: record exposure, gain, white balance, processing and pixel format.
  • Electrical pairing: verify the light, controller, wiring and any pulse requirements.
  • Validation: reserve independent samples and define borderline handling.
  • Maintenance: document reference checks and revalidation after component changes.

Start the camera configuration workflow once those requirements are written down. If the boundary between colour classification and instrument-based measurement remains unclear, send representative images, defect examples and acceptance criteria through application support before selecting the final parts.

Questions

Can RGB thresholds work for production colour inspection?

Yes, when illumination, geometry and camera processing remain fixed, RGB ranges can separate clearly different production classes. The thresholds must be validated against acceptable variation and known rejects. Raw channel differences should not be presented as standardized colour differences or transferred unchanged between different camera setups.

Should colour inspection use hue or CIELAB?

Use hue primarily for separating distinct colour families with sufficient saturation. Consider profiled CIELAB measurements when the decision concerns shade differences against an approved reference. Neutral colours, weak signals and glossy reflections need special handling because hue alone can become unstable or misleading.

Does white balance make a camera colour calibrated?

No. White balance adjusts relative channel responses using a neutral reference, but it does not characterize every material colour. A colour-calibrated workflow also needs suitable reference patches, a defined processing pipeline and validation across the actual colour range, illumination and surface conditions.

When is a spectrophotometer needed instead of camera-only inspection?

Use the agreed reference instrument when acceptance requires standardized measurements, spectral information or close agreement between sites. An inline camera can still inspect production after qualification against representative samples. Materials with angle-dependent appearance, fluorescence or translucency may need additional measurement conditions beyond a single camera view.