AI Glossary / Computer vision and multimodal AI / Intermediate

Watershed segmentation

Definition

Watershed segmentation is an image-partitioning method that treats a numerical image as a landscape and separates the regions reached by competing floods. Floods begin at minima or supplied markers, and their meeting boundaries define divisions. The landscape can be derived from edges, distances or other image information rather than raw brightness alone.

What it means

The goal is to divide an image into meaningful regions, often to separate objects that touch. A simple foreground threshold can identify a connected cluster without revealing how many individual objects it contains. Watershed can introduce divisions within that cluster when the chosen landscape and markers support them.

The algorithm does not inherently know what a seed, cell or manufactured part is. Its regions reflect the supplied numerical surface and starting conditions. Whether those regions correspond to real objects must be checked.

Marker-controlled watershed gives more control than flooding every small minimum. It uses selected starting regions, which may be provided manually or derived automatically. Good markers are evidence or hypotheses about region interiors, not guaranteed object identities.

How it works

A workflow first constructs the surface to be flooded. An edge-strength image can place high values at likely boundaries. For touching rounded objects, another approach computes distance from the foreground to the background and floods the negative distance image from markers near distance peaks.

Each marker receives a label. Regions expand according to the landscape and neighborhood rules until competing labels meet. A mask can restrict the allowed region. Implementations differ in how they resolve ties, represent boundaries and handle connectivity.

Noise can create many small minima and lead to excessive splitting. Smoothing, marker selection or other preprocessing can reduce that problem, but overly aggressive processing can merge genuine objects. Segmentation quality therefore depends on the whole pipeline, not just the final watershed call.

Three practical examples

  • A seed-inspection workflow separates touching seed silhouettes before estimating individual projected areas.
  • A materials-imaging researcher divides visible particle clusters into candidate particles and checks the boundaries against annotated examples.
  • A document-analysis experiment uses marker-guided regions to separate selected graphical elements from a structured background.

Think of it this way

Think of rain filling neighboring valleys from separate starting pools. Where the rising pools would meet, a dividing line keeps their labels distinct.

The analogy is limited because the landscape is a mathematical representation, not necessarily the photographed surface's physical height. The algorithm also follows discrete pixel rules, and a watershed line is not proof of a real object boundary.

Worked example

Two basins and a dividing ridge

Consider a one-dimensional landscape with heights 0, 1, 3, 1 and 0 at positions 1 through 5. Place marker A at position 1 and marker B at position 5. Allow movement only between adjacent positions.

As flooding reaches height 1, A covers positions 1 and 2, while B covers positions 4 and 5. The central position 3 has height 3 and separates the two basins until the floods reach that level.

In a boundary-preserving interpretation, position 3 can be designated as the dividing boundary. Other implementations may assign a tie location according to their rules, so the exact output convention must be specified.

Now remove marker B and use a marker-controlled procedure with only A. There is no second supplied label competing for the right-hand basin, so the method need not produce two object labels. Alternatively, adding an unnecessary third marker can create an extra region even though no third physical object exists.

This example distinguishes landscape from markers without simulating a particular library. For counting, a neat boundary must still be checked against actual object numbers and extents.

Illustrative case study

Illustrative case study - fictional

A fictional seed supplier tests image-based size grading on samples spread over a tray. Thresholding correctly identifies most seed pixels, but touching seeds form single connected clusters and receive inflated area estimates.

The team introduces distance-based markers and watershed separation. It then finds that textured or elongated seeds sometimes receive multiple markers, causing one seed to be counted twice. Rather than accepting every new region as an object, it reviews marker placement and tests difficult shapes separately.

Its evaluation records merged seeds, split seeds and area error against reviewed examples. This illustrates development, without claiming measured improvements.

Common misconceptions and mistakes

  • Watershed does not automatically recognize semantic object categories.
  • Raw image brightness is not the only possible flooding surface, and may be a poor choice for a task.
  • More markers do not necessarily produce a more accurate segmentation.
  • A clean-looking boundary can still split one real object or merge parts of different objects.
  • A thresholded foreground mask and an instance segmentation answer different questions: which pixels are foreground versus which individual object owns each pixel.

Business use

Watershed can be useful for counting and measuring objects when a suitable image representation exposes their separation. It is often attractive in controlled inspection settings, but its assumptions should be matched to the objects and acquisition conditions.

Evaluate merged and split instances as well as pixel overlap. For measurement workflows, assess how boundary errors affect reported sizes. Record marker generation, preprocessing, connectivity and background handling. Check variable lighting, touching objects and unusual shapes before relying on a pipeline calibrated to a few easy images. Review uncertain clusters instead of forcing a confident count.

People also ask

Does watershed require machine learning?

No. It is a classical segmentation method. Learned predictions can supply markers or a boundary surface, but they are optional components.

Why can it produce too many regions?

Small variations can create extra minima, or marker generation can supply several competing labels inside one object.

Can it separate every touching pair of objects?

No. Success depends on informative boundaries or shape cues and suitable markers. Some contacts remain ambiguous in the available image.

Check your understanding

A single seed receives two independent interior markers and is divided into two labeled regions. Does the watershed output prove that two seeds were present?

Answer: No. The split may reflect an incorrect marker hypothesis rather than a physical separation.

Related terms

  • Image segmentation
  • distance transform
  • connected components
  • marker-controlled segmentation
  • instance segmentation
  • mathematical morphology

Learn next

Draw two touching shapes and compare their foreground mask with their distance-to-background map. Place one marker in each shape, then deliberately add and remove markers. Observe how marker choices change the interpretation before using the regions for counting.

More in Computer vision and multimodal AI

  • Von Kries adaptation - Von Kries adaptation is a model of chromatic adaptation in which the three cone-response channels are adjusted by separate multiplicative gains.
  • Ward histogram-based tone mapping - Ward histogram-based tone mapping is a high-dynamic-range image reproduction approach that adjusts a luminance histogram to fit a display's range while...
  • Warp (image warping) - An image warp is a geometric transformation that changes where image content appears by mapping coordinates between a source image and a destination image.
  • Wavefront coding - Wavefront coding is a computational imaging approach that deliberately modifies an optical system's phase response and then digitally reconstructs the...
  • Weak learner - A weak learner is a learning algorithm that can produce a predictor with a modest advantage over a specified baseline under stated conditions.
  • Weiss intrinsic-image estimator - The Weiss intrinsic-image estimator is a method for separating a fixed reflectance image from changing illumination in an image sequence.

Sources

Sources: scikit-image, Watershed segmentation: https://scikit-image.org/docs/stable/auto_examples/segmentation/plot_watershed.html ; OpenCV, Image Segmentation with Watershed Algorithm: https://docs.opencv.org/4.13.0/d3/db4/tutorial_py_watershed.html . Relevant documentation on marker flooding, distance-based separation, oversegmentation and output boundaries was reviewed. The one-dimensional example is illustrative and was not executed in either library.

Previous: Wasserstein loss Next: Watkins Q(lambda)

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer