Perform the following steps to use skimage.morphology module's implementation of a morphological watershed for binary image segmentation:
- First, read the image of input binary circles and convert it into grayscale with an unsigned integer type:
image = img_as_ubyte(rgb2gray(imread('images/circles.png')))
- Compute the exact Euclidean distance transform and find peaks in it, labeling them subsequently to use them as markers for the watershed algorithm:
distance = ndi.distance_transform_edt(image)local_maximum = peak_local_max(distance, indices=False, footprint=np.ones((3, 3)), labels=image)markers = ndi.label(local_maximum)[0]
- Now, run the watershed algorithm with the marker created to get the output segmentation ...