# What is HSV segmentation, and how does it find eggs on a conveyor?

> HSV segmentation separates pixels by colour using hue, saturation and value, instead of red, green and blue. In Vigiovo, a pixel is shell when its hue is warm (red to yellow), its saturation is at least 45 and its brightness is at least 120, on a scale of 0 to 255. That keeps the grey and dark conveyor rollers out of the mask.

Updated: 2026-10-09 · URL: https://vigiovo.com/en/resources/hsv-colour-segmentation-for-eggs · Português: https://vigiovo.com/recursos/segmentacao-hsv-de-ovos.md

## Key takeaways

- HSV separates colour (hue) from brightness (value) and colour intensity (saturation), which makes the rule less dependent on light than a rule in RGB.
- In Vigiovo, shell is a pixel with a warm hue, saturation of at least 45 and brightness of at least 120, on a scale of 0 to 255.
- The conveyor rollers are grey and dark, so the colour rule leaves them out.
- White shells have low saturation and need other thresholds: calibrate with eggs from your own production before trusting the mask.

## What is HSV segmentation?

HSV segmentation is a case of [colour segmentation](https://vigiovo.com/en/resources/glossary#colour-segmentation): separating the pixels of an image by colour, using three measures. Hue (H) is the basic colour, such as red or yellow. Saturation (S) shows how vivid it is. Value (V) shows how light it is. The result is a mask that says, for each pixel, whether it belongs to the egg or to the background.

For someone who knows eggs, the idea is simple: a shell has a characteristic colour, and the rule looks for that colour at every point in the image. This is the first step in Vigiovo, before any measurement of dirt or cracks. The full flow is described in [how it works](https://vigiovo.com/en/how-it-works).

## Why use HSV instead of RGB?

HSV separates colour from brightness, and RGB does not. In RGB, a pixel's colour is a combination of three channels (red, green and blue). A shadow or a change in light scales the three channels together, so the colour seems to change in all of them at once. In HSV, the same shadow mostly changes value, while hue stays similar, which makes the colour rule more stable.

HSV does not replace stable light. If the colour of the lighting changes, the hue also shifts, and the mask needs recalibration. Measuring colour in [Lab space](https://vigiovo.com/en/resources/lab-colour-space-for-shell-stains) faces a similar challenge when the goal is to find stains.

## Which thresholds separate the shell from the rollers?

A pixel enters the shell mask when it passes three tests at once: a warm hue, from red to yellow; a saturation of at least 45; and a brightness of at least 120, on a scale of 0 to 255. Grey rollers have little saturation, and dark rollers have little brightness, so both stay out.

**How the rule treats four kinds of pixel**

| Pixel | Test | Result |
| --- | --- | --- |
| Brown or cream shell | warm hue, saturation of at least 45 and brightness of at least 120 | enters the egg mask |
| White shell | low saturation, which may not reach 45 | may stay out |
| Grey conveyor roller | low saturation | stays out |
| Dark conveyor roller | low brightness | stays out |

After the mask, morphological opening and closing remove noise and close small holes, and components smaller than 150 pixels are dropped. The logic of those operations is in [mathematical morphology](https://vigiovo.com/en/resources/mathematical-morphology-in-inspection).

These values are Vigiovo's configuration, not a legal standard, and they are adjusted during the calibration of each line.

## Why do white eggs need other thresholds?

White eggs do not fit the default thresholds. A white shell has low saturation and can fall below the limit of 45, and a bluish shell falls outside the warm hue range. The default thresholds were set for brown and cream eggs, so a line with white shells needs recalibration of hue and saturation.

Calibration should use eggs of the same colour, under the same light as production. If the belt is close in colour to the shell, part of the belt gets into the mask, and that error carries into every later measurement. The full case is in [white vs brown eggs on camera](https://vigiovo.com/en/resources/white-vs-brown-eggs-on-camera).

## What are the limits of colour segmentation?

Colour segmentation sees the surface, not the inside. It finds the shell, but it does not tell whether the egg is cracked inside, and it does not separate two touching eggs: that task belongs to [watershed](https://vigiovo.com/en/resources/glossary#watershed).

Dirt with a colour close to the shell stays inside the mask, which is why dirt is measured later, on each isolated egg. A poor mask affects every later step, and that is why calibration comes before any class decision. For what a camera sees and what it misses, see [candling or computer vision](https://vigiovo.com/en/resources/candling-vs-computer-vision).

## Frequently asked questions

### What do the letters HSV stand for?

HSV stands for hue, saturation and value, three measures of colour. In egg segmentation, hue tells whether the colour is a shell colour, saturation tells whether it is vivid, and value tells whether it is light. Together they separate the shell from the grey and dark conveyor rollers.

### Why can a white shell fall outside the colour mask?

A white shell has low saturation, and a weakly saturated pixel may not pass the mask's limit. A bluish shell also falls outside the warm hue range. That is why white eggs need calibration with eggs of the same colour, under the same light as production.

### Does colour segmentation detect cracks or dirt?

Not directly. Colour segmentation only finds the area of the shell. Cracks and dirt are measured later, on each isolated egg. A surface camera also cannot see the inside, such as the air cell and the yolk, so candling is still needed for those.

## 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

- [What image resolution is enough to grade eggs?](https://vigiovo.com/en/resources/image-resolution-for-egg-grading.md) (Explainer, 2026-10-09): What camera resolution is enough to grade eggs: why pixels per egg matter, how the egg radius works as a ruler and how to choose a camera for your line.
- [Watershed: separating touching eggs in an image](https://vigiovo.com/en/resources/watershed-for-touching-eggs.md) (Explainer, 2026-10-09): How the watershed algorithm separates touching eggs in an image, using the distance transform, one seed per egg and the boundary between each pair, as Vigiovo does.
- [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.
