Performs a marker-based image segmentation using the watershed algorithm.
imout = imwatershed(imin)
Input 8-bit 3-channel image.
Double precision single-channel image (map) of markers. It should have the same size as image.
Output labelled image
The function implements one of the variants of watershed, non-parametric marker-based segmentation algorithm.
S = imread(fullpath(getIPCVpath() + "/images/three_objects.png"), IMREAD_COLOR = 1); Sgray = rgb2gray(S); Sb = im2bw(Sgray,0.1); Sd = imdistransf(Sb); dist = Sd > 0.4; [markers,n] = imlabel(dist); markers(1:5,1:5) = 255; Sw = imwatershed(S, markers); imshow(Sw,hsvcolormap(3)); | ![]() | ![]() |
1. OpenCV 4.1.2 Online Documentation