Detection Engine

Watershed

Segmenting by flooding a landscape from seeds

View
Definition
Treat the image as a landscape, each pixel's intensity its height. Let water well up from a few chosen springs. It spreads in an order the terrain sets, and wherever two floods meet, a barrier goes up. Watershed (global) does this with a Seeds image as the springs and a Topographic Map as the terrain. The barriers cut one connected region into separate events, separating touching objects.
Supporting
User Interface - Image Viewer + Toolbar
Video · Supporting
Topographic Segmentation
Intensity becomes height
Closed contours, in theory
Barriers enclose every basin
Seeds are required
Every flood starts at a seed
Versatile Input
The map determines where barriers fall

How It Works

Watershed (global) sits in a layer's Detection section (Add > Operations (advanced) > Watershed (global)). It takes two images. The Seeds image marks where flooding starts: its non-zero pixels are the water sources. The Topographic Map is the relief, read with each pixel's intensity as its height, and it sets the priority with which the seeds grow.

Water from every source spreads over the relief, and where water from different sources meets, the engine builds a barrier. The set of barriers is the segmentation, and the result is a coded imageLoading... of events. An optional Mask limits the flooding to its white areas.

The word "global" has a specific meaning here. The engine considers the continuity of information from one field of viewLoading... to the next, which takes several passes, and Maximum iterations caps them. Stitch seeds handles seeds that continue across fields, and Remove seedless merged labels drops resulting events that aren't connected to any seed.

The classical NucleiLoading... engine is a separate matter. Its chapter in the Engines Reference doesn't describe its internal method or mention a watershed, so this page makes no claim about how Nuclei splits touching nuclei.

Simplified

Mark a seed inside each object you want, and give the engine a height map. Water spreads from every seed, and wherever two floods meet, a wall goes up. The walls are the boundaries, and the walled-off regions become the objects.

Science Behind It

The textbook watershed. In image processing generally, the watershed comes from mathematical morphology, and its classic form floods from every local minimum of the image. That form has a well-known habit. Noise and small dips each make a basin of their own, so you get many tiny regions where you expected a few, which is called over-segmentation.

Seeds as the cure. The standard remedy is the marker-controlled watershed: you supply markers, ideally one per object, and only the markers may grow. StrataQuest's Watershed (global) works this way by design, since flooding starts only from the Seeds image. A common textbook recipe makes the markers from the cores of the objects, often shaped with morphological operationsLoading..., and the relief from a distance map or a gradient image.

Why the contours close. In the textbook form every pixel ends up in a basin or on a barrier, and a gap in a barrier would let two floods merge, so each basin is enclosed. Edge detectors such as SobelLoading... and CannyLoading... detect edges pixel by pixel and can leave gaps that need linking. The Engines Reference doesn't state the closure property for its engine; it follows from the algorithm as usually defined.

Shape versus brightness. The relief determines where barriers fall. In the textbook recipe, the distance map of a mask is turned upside down so each object's center becomes a basin; two touching round objects then form two basins joined at a narrow waist, and the barrier runs along that waist. That is how a watershed splits objects of the same brightness by shape alone. The reference example takes its relief from a Distance Map computed with the membranes as reference, and its seeds from the fat cell bodies.

Simplified

Left to itself, a watershed turns every small dip into its own region, like puddles across a field. Seeds settle that: only the places you mark get to grow. Because every region ends up enclosed by barriers, a watershed doesn't leave a boundary with a gap in it, which edge detectors can't promise.

Parameters & Settings

ParameterDescription
SeedsThe image representing the starting points of the flooding. Its non-zero pixels are the water sources.
Topographic MapThe image representing the topographic map used to prioritize flooding; each pixel's intensity is read as its height.
MaskApplies the watershed transformation only in the indicated (white) areas.
Maximum iterationsThe maximum number of iterations. The global watershed considers continuity from FOV to FOV, which needs several iterations.
Remove seedless merged labelsEnables or disables removal of resulting events (labels) not connected to a seed.
Stitch seedsEnables or disables stitching for seeds, for seeds that continue from one FOV to another.

The seeds determine what gets separated, so look at them first. Two seeds in one object split it; one seed shared by two objects can't separate them. When the result disappoints, check the Seeds image before you touch the map.

Source: StrataQuest 8.1 Engines Reference, ch. 43 (pp. 547–549); ch. 26 (pp. 449–454); ch. 14 (p. 405); ch. 6.6 (p. 195).

Simplified

Two inputs do the work: Seeds, one mark per object you want, and Topographic Map, the terrain the floods spread across. A Mask can fence off where flooding is allowed.

Practical Example

The Engines Reference example separates fat cells in a brightfield sample, where the cells pack together and share membranes.

  1. Seeds: a mask of the fat cell bodies as white areas. The reference's Grow labels example makes a fat cell seeds mask with a thresholdLoading... on the original image.
  2. Topographic Map: a Distance MapLoading... engine with the membranes as reference.
  3. Mask: flooding allowed everywhere, with a fully white binary mask.
  4. Add Watershed (global) in Detection with those three inputs.

Each seed grows until it meets its neighbors, and the result is a coded imageLoading... with each fat cell as its own event, ready for Standard MeasurementsLoading.... Without the barriers, a sheet of touching cells would be one connected region.

Simplified

Fat cells sit packed together like foam. Put a seed in each cell body, use the distance from the membranes as the terrain, and the watershed walls the cells off from one another, so each one is counted and measured on its own.

Connected Terms

Share This Term
Term Connections