はウォータシェド変換を画像に適用する
SegmentedImage = Watershed(Image, Marker);
2次元の行列で、型はuint8である
2次元の行列で、型はbooleanで、値が%tの画像はウォータシェド変換の最初点である
行列で、次元はImageと同じで、型はint32である
本関数はウォータシェド変換を画像に適用する。
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)); | ![]() | ![]() |