watershed segmentation
Watershed segmentation borrows a vivid metaphor from geography. Imagine the image as a landscape where brightness (or more often the gradient magnitude — how fast intensity changes) is height: flat, uniform regions are valleys, and sharp edges are ridges. Now imagine rain falling, or water rising from the bottom of each valley. Each pool of water grows until it is about to merge with a neighboring pool; at exactly those meeting lines you build a dam. When the flooding finishes, the dams are the segment boundaries and each catchment basin is one region.
Made precise, the classic Vincent-Soille algorithm sorts pixels by height and floods the surface level by level, assigning each pixel to the basin of a local minimum, and marking watershed lines where two basins would otherwise touch. A naive run treats every tiny local minimum as a seed, which catastrophically over-segments a noisy image into thousands of fragments. The standard fix is marker-controlled watershed: you (or a preprocessing step) supply a small set of markers — one inside each true object and some for the background — and flood only from those, so the number of regions is controlled.
Watershed shines at separating objects that touch but each have a distinct intensity center, which is why it is a staple for counting cells, grains, or coins. A typical modern pipeline computes a distance transform inside a binary foreground mask (peaks sit at object centers), uses those peaks as markers, and runs watershed to split the clump. It is also used as a final step to cut apart instances that a CNN merged.
Run watershed naively on a raw noisy image and you get a shattered mess — the over-segmentation is not a bug, it is what unconstrained flooding does. Markers (or smoothing the surface first) are essential, not optional.