【发布时间】:2018-02-20 12:30:54
【问题描述】:
我对使用分水岭算法分离图像上的特征很感兴趣。使用 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')
特征分离似乎有些随机,从中间的延长特征可以看出。但是,分水岭算法似乎没有任何参数可用于优化其性能。你能建议如何引入这样的参数,或者更好的算法来处理数据。
额外问题:我有兴趣首先使用 bwconncomp 分离我的图像,然后有选择地将分水岭算法仅应用于某些区域。假设我知道我想将算法应用到哪些 cc.PixelIdxList 区域 - 如何获得具有分离组件的新 PixelIdxList。
【问题讨论】:
-
嗨,Mehrdad,感谢您的建议。我之前确实看过。问题是最终结果将一些单元格随机分成两半,这是不可取的。如果可以控制最大分离厚度(只是弥补),那就太好了
标签: matlab image-processing watershed