正如 Adi Shavit 所说,图像非常嘈杂。当直接在图像上使用分水岭时,这会导致过度分割(因为图像中有很多极值)。
您确实需要执行某种预处理来平滑图像。如果不想使用模糊,可以imreconstruct
在找到极值之前尝试形态重建( )。
% if img is your original grayscale image
wSize = 6;
se = strel('disk', wSize);
% opening by reconstruction - to remove specks in the dark background
imgEroded = imerode(img, se);
imgRecon = imreconstruct(imgEroded, img);
imgReconComp = imcomplement(imgRecon);
% opening by reconstruction - to homogenize the pixels in the foreground(clouds)
imgEroded2 = imerode(imgReconComp, se);
imgRecon2 = imreconstruct(imgEroded2, imgReconComp);
minima = imregionalmin(imgRecon2);
覆盖在原始图像上的最小值如下所示 -
您可以试验结构元素的大小/形状,看看是否能得到更好的结果。
您也可以使用极值作为种子对梯度图像执行分水岭分割,但这可能不会产生有意义的结果(看起来您无论如何都没有尝试执行分割)。