Watershed#

Principle#

The concept of watershed considers the image as a topographic map: high intensities in the image are the mountains and low intensities are the valleys. The principal objectives of the watershed segmentation method is to find the crest lines of the topographic map, where a drop of water placed on one of these crest lines would be equally likely to fall on one side or the other of the line.

../_images/watershed-concept.svg

Fig. 72 A grayscale image (left) and its 3D representation as a topographic map (right). The crest line is the top of the mountain in the shape of a “b”.#

The basic idea of watershed segmentation is to flood the topographic map and letting water rise through the valleys at a uniform rate. When the rising water of two distinct valleys is about to merge, a dam is built to prevent the merging. When water covers the entire surface of the image, the dams correspond to the segmentation boundaries.

../_images/watershed-animation.svg

Fig. 73 Illustration of water flooding on a cut at row 150 (see Fig. 74). The number corresponds to the water level, the dams are shown in red.#

../_images/watershed-cut.svg

Fig. 74 The grayscale image with the watershed boundaries (dams) shown in red. The profile considered in Fig. 73 is plotted in green.#

Application to an image#

Generally, the contours of the objects do not correspond to the crest lines, so the watershed has to be applied to the gradient of the image (see Fig. 75).

../_images/cells-watershed-ok.svg

Fig. 75 An image (left), its gradient (center), and the result given by the watershed. The contours are computed by using the Sobel filter.#

Limitations#

One of the limitations of the watershed method appears when there are many local minima in the image: the watershed leads to over-segmentation because each local minimum will produce a segment. This phenomenon is illustrated Fig. 76 where the image is the same as in Fig. 75 but degraded by additive noise and JPEG. Therefore the image gradient now presents some small local minima.

../_images/cells-watershed-oversegmentation.svg

Fig. 76 Degraded version of Fig. 75 (left), its gradient (center), and the result given by the watershed (right). Clearly, the result is not satisfactory.#

To reduce the number of segments, one can:

  • manually choose the watersheds of interest with markers (Fig. 77),

  • smooth (with a low-pass filter) the gradient before applying the algorithm (Fig. 78),

  • merge the local minima.

../_images/cells-watershed-markers.svg

Fig. 77 Same image as in Fig. 76 (left), its gradient and the chosen markers (center), and the result given by the watershed (right).#

../_images/cells-watershed-smooth.svg

Fig. 78 Same image as in Fig. 76 (left), the gradient of a smoothed version of the image (center), and the result given by the watershed (right).#