# What is the Lab colour space, and how does it help detect shell stains?

> The Lab colour space separates lightness (L) from the colour components (a and b). That makes it possible to find a stain of a different colour even when it is as bright as the shell, which a brightness-only measurement does not see. Vigiovo computes this colour deviation in parallel with brightness and excludes glare before deciding.

Updated: 2026-10-09 · URL: https://vigiovo.com/en/resources/lab-colour-space-for-shell-stains · Português: https://vigiovo.com/recursos/espaco-lab-manchas-na-casca.md

## Key takeaways

- Lab separates lightness (L) from the two colour components, a and b.
- A stain can be as bright as the shell and still have a different colour, and only the colour measurement reveals it.
- Vigiovo measures the Lab colour deviation in parallel with brightness and excludes glare from that measurement.
- Lab does not replace steady light, because lighting changes still alter the measured colour.

## What is the Lab colour space?

Lab is a colour space that separates lightness (L) from the colour components: a, which runs from green to red, and b, which runs from blue to yellow. In a space such as RGB, each channel mixes brightness and colour, so a change in light alters all three values at once.

In Lab, a change in brightness shows up mainly in L, and colour is concentrated in a and b. For inspection this is useful: a stain of a different colour still appears in a and b, even when the light changes the overall brightness of the shell.

## Why is measuring brightness alone not enough?

Measuring brightness alone lets through a stain that has the same lightness as the shell. It does not appear as a dark spot, but it does appear as a different colour, and only the colour measurement reveals it.

[Vigiovo](https://vigiovo.com/en/how-it-works) handles the two cases with separate measurements. The brightness measurement looks for what falls well below the [shading surface](https://vigiovo.com/en/resources/glossary#shading-surface) of each egg. The Lab colour measurement looks for colour deviations, in parallel. A stain that gets past one measurement can be caught by the other.

**Brightness alone or brightness with colour (practical assessment)**

| Measurement | What it sees well | Limitation |
| --- | --- | --- |
| Brightness only | Stains darker than the shell | Stains with the same brightness as the shell get through |
| Brightness and colour (Lab) | Dark stains and stains of a different colour | Depends on the light and the camera keeping the colour stable |

## How does Vigiovo use Lab to measure stains?

Vigiovo measures the Lab colour deviation in parallel with the brightness measurement. First, the shell mask is built in HSV, as described in [how Vigiovo grades eggs](https://vigiovo.com/en/how-it-works), and only then does the system look for stains within each egg.

The colour and brightness measurements are made in parallel, and glare is excluded from the dirt measurement. When the stains cover 3% or more of the visible shell, the egg is graded as dirty.

## Why must glare stay out of the colour measurement?

Because glare is a very bright, barely saturated area, and it can be read as a colour deviation if it is not excluded. Glare is not dirt and should not affect the decision.

Glare moves when the egg turns, so it does not form a fixed stain. Even so, in a single frame it can look like a stain. That is why exclusion and voting between measurements work together, as explained in the article on [glare and false dirty grades](https://vigiovo.com/en/resources/glare-and-false-dirty-grades).

## What are the limits of the colour measurement?

The colour measurement sees only the surface of the shell, and it does not say what caused the colour. A surface camera does not see the interior of the egg, and the colour measurement does not reach very fine stains or stains whose colour is very close to the shell.

- A stain whose colour is close to the shell may deviate too little to pass the limit.
- The measured colour depends on the light, so the lighting must be stable.
- Colour does not identify the substance: the system measures the dirty area, not the origin of the stain.

Review a sample of eggs marked clean from time to time, to see what the camera is letting through. The method is in [calibrating with labelled eggs](https://vigiovo.com/en/resources/calibrating-with-labelled-eggs).

## Frequently asked questions

### Does Lab need a special camera?

No. Lab is a mathematical conversion of the image the camera already captures, so it needs no different hardware. What matters is steady light, because the measured colour depends on it, and the camera's white balance must be locked.

### Can a colour stain still get past Lab?

It can. Very small stains, or stains with a colour close to the shell, fall below what the measurement separates. The camera only sees the surface, and no measurement guarantees that every stain is seen. Review a sample of clean eggs to estimate what is getting through.

### Do I need to recalibrate colour if the bird strain changes?

Yes. Shell colour differs between strains, and the colour thresholds were tuned for the shell in the calibration. Before returning to production, repeat the calibration with eggs from the new strain and record the date of the change.

## Sources

- [Changing Colorspaces](https://docs.opencv.org/4.x/df/d9d/tutorial_py_colorspaces.html), OpenCV documentation
- [Como o Vigiovo classifica ovos sem IA / How Vigiovo grades eggs without AI](https://vigiovo.com/como-funciona), Vigiovo

## Read next

- [Mathematical morphology in visual inspection](https://vigiovo.com/en/resources/mathematical-morphology-in-inspection.md) (Explainer, 2026-10-09): What mathematical morphology is, how erosion, dilation, opening and closing clean an egg mask, and how Vigiovo uses these operations in inspection.
- [Glare and false 'dirty' grades: how to avoid them](https://vigiovo.com/en/resources/glare-and-false-dirty-grades.md) (Guide, 2026-10-09): Why glare causes false dirty grades, how Vigiovo excludes glare and votes across three measurements, and what to do when a dirty grade turns out to be glare.
- [Candling vs computer vision: what each one detects](https://vigiovo.com/en/resources/candling-vs-computer-vision.md) (Comparison, 2026-10-09): Candling compared with camera inspection in egg grading: which defects each detects, speed, record keeping and why the two methods work best together.

## How Vigiovo helps

Vigiovo grades eggs on the conveyor as clean, dirty, cracked or unverified, in real time, with deterministic computer vision: every decision comes with the measurements behind it, on an ordinary CPU. https://vigiovo.com/en/how-it-works.md

4 min read.
