segments image by watershed transform
SegmentedImage = Watershed(Image, Marker);
2D matrix of type uint8
2D matrix of type boolean, blobs consisting of %t pixels are seeds of watershed transform
2D matrix of type int32, has the same dimensions as image
This function applies a watershed transform to an image.
global IPD_PATH; RGB = ReadImage(IPD_PATH + 'demos\teaset.png'); Image = RGB2Gray(RGB); global EDGE_SOBEL; Gradient = EdgeFilter(Image, EDGE_SOBEL); EdgeImage = ~SegmentByThreshold(Gradient, 60); DistanceImage = DistanceTransform(EdgeImage); ThresholdImage = SegmentByThreshold(DistanceImage, 8); MarkerImage = SearchBlobs(ThresholdImage); SegmentedImage = Watershed(Gradient, MarkerImage); figure(); ColorMapLength = length(unique(SegmentedImage)); ShowImage(SegmentedImage, ... 'Result of Watershed Transform', ... jetcolormap(ColorMapLength)); | ![]() | ![]() |