Image segmentation is the partitioning of an image into distinct regions or categories that correspond to different objects or parts of objects. In this recipe, you will learn how to use a region-based segmentation method to a binary image using the morphological watershed algorithm. We can think of a grayscale image as a topographic surface. If we flood this surface from its minimum values and prevent the merging of waters from different sources, then the image gets partitioned into two different sets, namely, the catchment basins (segments) and the watershed lines. To prevent over-segmentation, a pre-defined set of markers is used and the flooding of the surface starts from these markers. The following are the steps involved in the segmentation of an image by the watershed transformation:
- Find the markers and the segmentation criterion (the...