# What is a shading surface, and how does it measure dirt on the shell?

> A shading surface is a smooth surface fitted to each egg's brightness, so the normal gradient of the dome is not counted as dirt. Vigiovo fits it by least squares after discarding outliers, and whatever falls well below it is measured as a stain. Each stain is compared with its own egg, not with one fixed value for the whole image.

Updated: 2026-10-09 · URL: https://vigiovo.com/en/resources/shading-surface-dirt-measurement · Português: https://vigiovo.com/recursos/superficie-de-sombreamento.md

## Key takeaways

- A clean shell is not evenly bright: the dome of the egg creates a gradient that is normal.
- The shading surface is a quadratic surface fitted by least squares to each egg's brightness.
- Outlier pixels, such as glare, are discarded before the fit so that they do not pull the surface.
- A stain is what falls well below the surface of its own egg, not below one global value for the image.

## Why isn't a clean egg evenly bright?

A clean egg is not equally bright over its whole shell. The top of the dome receives more light and the edges are darker, gradually. That gradient is part of the shape of the egg, not dirt. If an inspection used one brightness threshold for the whole image, the edges of a clean egg could look dirty.

The fix is to compare each pixel with the normal brightness at that point of the egg. That reference is the [shading surface](https://vigiovo.com/en/resources/glossary#shading-surface). For someone who knows eggs, it is like comparing the shell with itself, without the stain, and not with the shell of another egg.

## How is the surface fitted to each egg?

Vigiovo fits a quadratic surface, a smooth second-degree dome, to each egg's brightness by least squares. Least squares chooses the surface that stays closest, overall, to the shell pixels. Because the surface is quadratic, it follows the dome without chasing local details such as a stain.

Before the fit, pixels that lie far outside the pattern are discarded. Specular highlights are the typical case: a point of intense brightness would pull the surface upwards if it were kept. Without those points, the surface again represents the clean shell.

**The two steps of the fit for each egg (practical description)**

| Step | What it does | Why |
| --- | --- | --- |
| Fit | a quadratic surface fitted by least squares to the egg's brightness | it follows the normal gradient of the dome |
| Outlier removal | pixels far from the surface are discarded | glare and marks do not pull the surface |

## How does dirt show up as a residual?

After the fit, each shell pixel is compared with the surface of its own egg. If its brightness falls well below the surface, the pixel is a candidate stain; if it follows the surface, it is clean shell. The difference between the pixel and the surface is the residual, and that is what Vigiovo measures.

In parallel, Vigiovo measures colour deviation in [Lab space](https://vigiovo.com/en/resources/glossary#lab-colour-space), which catches stains that have the same brightness as the shell but a different colour. Specular highlights stay out of that colour measurement. If stains cover 3% or more of the visible shell, the egg is dirty.

## Why don't reflections count as dirt?

A reflection is a very bright point, above the surface, and the dirt rule only looks at what falls below it. But a reflection can still pull the surface upwards if it enters the fit, which is why it is discarded first. It is also kept out of the colour measurement.

That care is part of the reason why, on video, an egg is rejected only when the defect shows up in more than one measurement, as explained in [how it works](https://vigiovo.com/en/how-it-works). Glare and its false dirty grades are covered in [glare and false dirty grades](https://vigiovo.com/en/resources/glare-and-false-dirty-grades).

## What are the limits of the shading surface?

The surface describes the normal shape of the egg, so it works best when the shell is smooth and the egg has a regular shape. A badly deformed egg, large marks or strong shadows can produce a surface that does not follow the real dome.

The method also has a physical limit: a surface camera does not see the inside of the egg. Internal defects do not show in this measurement, and [candling](https://vigiovo.com/en/resources/glossary#candling) remains necessary. For the comparison between the two approaches, see [candling or computer vision](https://vigiovo.com/en/resources/candling-vs-computer-vision).

## Frequently asked questions

### What is a shading surface in one sentence?

It is a smooth second-degree surface fitted by least squares to each egg's brightness. It represents how the brightness of a clean shell should be at that point, and whatever falls well below it is treated as a stain.

### Why not use one fixed brightness threshold for every egg?

Because the shell has a natural gradient that changes from point to point, and a fixed threshold would confuse the dark edge of a clean egg with dirt. Comparing each pixel with the surface of its own egg avoids that error without relying on one global value.

### Does the shading surface detect cracks?

No. It measures stains, which are areas darker than the shell or of a different colour. Cracks are found by a different path, with black-hat and top-hat filters. Internal defects such as the air cell and the yolk do not show in these measurements, because the camera only sees the surface.

## Sources

- [Como o Vigiovo classifica ovos sem IA / How Vigiovo grades eggs without AI](https://vigiovo.com/como-funciona), Vigiovo

## Read next

- [Lab colour space for detecting shell stains](https://vigiovo.com/en/resources/lab-colour-space-for-shell-stains.md) (Explainer, 2026-10-09): How the Lab colour space separates lightness from colour to find stains of a different colour on the shell, and why Vigiovo excludes glare from that measurement.
- [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.
