The watershed transformation is a popular image-processing algorithm that is used to segment an image into homogenous regions quickly. It relies on the idea that when the image is seen as a topological relief, the homogeneous regions correspond to relatively flat basins, delimited by steep edges. As a result of its simplicity, the original version of this algorithm tends to over-segment the image, which produces multiple small regions. This is why OpenCV proposes a variant of this algorithm that uses a set of predefined markers that guide the definition of the image segments.
Segmenting images using watersheds
How to do it...
The watershed segmentation is obtained through the use of the cv::watershed function. The input for...