- Introduced by
- Serge Beucher and Christian Lantuéjoul
- Year
- 1979
- Type
- Morphological image segmentation
- Family
- Segmentation
What does it do?
Watershed segmentation is a morphological image processing method that partitions an image into regions by treating intensity (or a derived gradient or distance image) as a topographic surface, where each region corresponds to a catchment basin.
The method is credited to Beucher and Lantuéjoul (1979), and Meyer's 1994 paper on topographic distance and watershed lines is also a standard reference for it. It is most often used to separate touching or overlapping objects.
The intuition behind the method
Think of the image as a landscape of hills and valleys. Water poured into each valley would fill that basin and stop where it meets water from a neighbouring valley; the line where the two meet is a watershed line, a ridge that becomes a region boundary. Markers placed in each object (and in the background) act as the valleys that the flood starts from. Because boundaries form along ridges rather than at a fixed intensity threshold, the method can split objects that touch and would merge under simple thresholding. Its outcome depends heavily on where the water sources are placed.
History
Beucher and Lantuéjoul introduced the watershed method in 1979 in a workshop paper on the use of watersheds for contour detection. Meyer's 1994 paper, "Topographic distance and watershed lines", is a later reference on the topographic definition of watershed lines. Watershed is widely implemented in image processing software.
When to use it
Choose watershed when the image contains touching or overlapping objects whose boundaries appear as intensity edges or as necks in a binary mask, and when you can identify one marker per object, for example from a distance transform. It suits cell nuclei, clustered particles and similar objects where separation by a single threshold fails. Do not use it on noisy or low-contrast images without clear ridge structure, because the flooding will follow noise and fragment the image. Avoid it when markers cannot be defined reliably and automatic minima detection would produce many spurious regions. In such cases, plan for region merging or other post-processing from the start, or consider the preprocessing steps described under related methods such as image morphology and edge detection. Set and report the pixel connectivity (4- or 8-neighbourhood) and the number of markers per object explicitly, because both change the resulting boundaries.
Limitations and considerations
- Sensitive to noise: small intensity fluctuations create extra local minima, and each minimum can start its own region, causing oversegmentation.
- The result depends on the surface chosen; a poor gradient or a distance transform computed from a bad mask produces poor boundaries.
- Marker selection largely determines the outcome, and automatic marker detection from local minima is unreliable on noisy images.
- The raw output typically contains many small fragments, so region merging or morphological post-processing is usually needed before the segmentation is usable.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Places boundaries along ridges in the gradient or distance surface, so touching objects can be separated where a single intensity threshold would merge them.
- Produces closed, connected regions that partition the whole image, so every pixel receives a label.
- Marker-controlled watershed lets prior knowledge about object positions enter the segmentation directly through the marker placement.
- Works on any surface that has clear basin structure, including gradient images and distance transforms, so the same procedure can be adapted to different image types.
Applications
- Medical image analysis: separating touching cells or nuclei in microscopy images using distance-transform or gradient-based watershed.
- Industrial inspection: counting and separating overlapping objects such as coins or pills on a conveyor.
- Particle analysis: segmenting clustered particles where individual objects touch.
- Plant science: counting seeds or fruits in images where neighbouring objects touch.
How it works
How it works
Compute a surface that expresses object boundaries, typically a gradient (edge magnitude) image or a distance transform of a binary mask. Optionally apply morphological preprocessing such as erosion, dilation, opening or closing to suppress small minima and shape the regions. Place one marker in each object of interest and one in the background.
This method involves no learning or training. In this step the algorithm floods the surface outward from the markers, and each pixel is assigned to the marker whose flood reaches it first in the order of increasing surface height. The final segmentation is therefore determined by the surface, the markers and the pixel connectivity.
No model is applied here; this step labels the regions. Watershed lines are the pixels where floods from different markers meet, and these are kept as region boundaries. Each connected region receives a unique label, giving a label image in which every pixel belongs to one region.
Compare the labelled output with a reference segmentation when annotated data are available. Per-object overlap measures such as the Jaccard index (intersection over union) or the Dice coefficient show how well each region matches its reference object. Comparing the number of predicted regions with the number of reference objects reveals oversegmentation (more regions than objects, with many small fragments from spurious minima) and undersegmentation (fewer regions than objects, with distinct objects merged). Without reference data, inspect the result visually, overlaying the boundaries on the original image.
Common pitfalls
- Running watershed directly on raw intensity rather than on a gradient or distance transform, so that texture and noise define the basins.
- Using every local minimum of a noisy surface as a seed, which yields extreme oversegmentation.
- Skipping preprocessing (for example opening or closing) that would merge shallow minima before flooding.
- Reporting the raw watershed output without merging small regions, which can make the segmentation look far more fragmented than the image content supports.
Frequently asked questions
What is the difference between using watershed on gradient images versus distance transforms?
Watershed on a gradient image (edge magnitude) places boundaries at high-intensity edges, which suits images where object boundaries are clear. Watershed on a distance transform (where values represent distance from the object boundary) places boundaries at the necks between objects, so regions are organised around object centres. The choice depends on the image type and on whether edges or shape should define the regions.
Why does watershed often produce oversegmentation?
Oversegmentation occurs when many local minima exist in the gradient or distance surface, and each minimum starts a separate watershed region. Noise creates extra minima. To reduce it, preprocess the image with morphological operations such as opening or closing to remove shallow minima, or use marker-based watershed with carefully chosen seed points instead of automatic minima detection.
How do markers control the watershed algorithm?
Markers are seed points or seed regions that represent objects or background. In marker-controlled watershed, flooding starts only from the markers, so regions form around them rather than around every local minimum. This avoids the oversegmentation caused by automatic minima detection. Markers can be placed manually or derived automatically, for example by using eroded objects as markers.
What post-processing is typically needed after watershed segmentation?
Watershed often produces many small regions, so post-processing is usually needed. Common steps include morphological closing to join nearby fragments, merging adjacent regions that share similar properties, and removing regions that are too small. The appropriate steps depend on the application and should be checked against the reference data.
Related methods
Sources
Meyer, F. (1994). Topographic distance and watershed lines. Signal Processing, 38(1), 113–125.
Open DOI referenceBeucher, S., & Lantuéjoul, C. (1979). Use of watersheds in contour detection. International Workshop on Image Processing, Real-Time Edge and Motion Detection/Estimation, 2.1–2.12.
Open publication reference