首页 文章

Matlab分水岭算法 - 控制分离宽度

提问于
浏览
2

我有兴趣使用分水岭算法分离图像上的特征 . 使用matlab教程,我尝试编写一个小的原理证明算法,我可以在我的图像分析中进一步使用 .

Im = imread('../../Pictures/testrec.png');
bw = rgb2gray(Im);
figure
imshow(bw,'InitialMagnification','fit'), title('bw')

%Compute the distance transform of the complement of the binary image.
D = bwdist(~bw);
figure
imshow(D,[],'InitialMagnification','fit')
title('Distance transform of ~bw')

%Complement the distance transform, and force pixels that don't belong to the objects to be at Inf .
D = -D;
D(~bw) = Inf;

%Compute the watershed transform and display the resulting label matrix as an RGB image.
L = watershed(D);
L(~bw) = 0;
rgb = label2rgb(L,'jet',[.5 .5 .5]);
figure
imshow(rgb,'InitialMagnification','fit')
title('Watershed transform of D')

从中间的长时间特征可以看出,特征分离似乎有些随机 . 但是,分水岭算法似乎没有任何参数可用于优化其性能 . 您能否建议如何引入这样的参数,或者更好的算法来处理数据 .

Bonus Question :我有兴趣首先使用bwconncomp分离我的图像,然后选择性地将分水岭算法应用于某些区域 . 假设我知道要将算法应用于哪个cc.PixelIdxList区域 - 如何获得具有分离组件的新PixelIdxList .

Original Picture

enter image description here

Result of the algorithm

1 回答

  • 0

    分水岭变换不能分离凸形 . 没有办法改变这一点 . 凸形总是导致一个对象 .

    非常靠近凸起的斑点将总是导致流域效果不佳 .

    你有这个“有点随机”结果而不是单个盆地的唯一原因是几个像素有点偏离周长 .

    流域的结果通过加工前和加工后得到改善 . 但这对某个问题非常具体 .

相关问题