计算二维图像中分支的粗细

Computing the thickness of branches in a 2D image

我想测量图像中树枝的粗细。以下是从斐济得到的输出。

我想计算与每条边相关的平均厚度。所谓边缘,是指存在于任意两个分支点之间的线段。

关于如何进行的任何指示都会非常有帮助。

图片来源:ref

编辑: 节点是一个连接点或终点。如果不清楚以及是否需要进一步解释,请告诉我。例如,如果我们像 here 所示那样对上面的图像进行骨架化,则连接点或终点将是节点。如果有帮助,我可以分享上图的骨架版本。

编辑2:

{1 -> {36.4156, 23.8112, 0.},
 2 -> {83.4779, 151.809, 0.}, 
 3 -> {182.451, 145.504, 0.},
 4 -> {227.385, 86.2469, 0.}, 
 5 -> {311.9, 218.811, 0.},
 6 -> {483.204, 190.795, 0.}, 
 7 -> {601.916, 226.427, 0.},
 8 -> {780.405, 312.889, 0.}, 
 9 -> {974.959, 274.093, 0.},
 10 -> {656.313, 209.944, 0.}, 
 11 -> {815.08, 182.186, 0.},
 12 -> {923.162, 121.453, 0.}, 
 13 -> {353.554, 34.5667, 0.},
 14 -> {479.314, 87.3631, 0.}, 
 15 -> {662.5, 119.5, 0.},
 16 -> {759.72, 99.8905, 0.}, 
 17 -> {539.501, 34.4999, 0.},
 18 -> {712.917, 26.8174, 0.}, 
 19 -> {896.5, 65.5, 0.},
 20 -> {143.654, 379.583, 0.}, 
 21 -> {203.382, 270.926, 0.},
 22 -> {311.084, 354.623, 0.}, 
 23 -> {495.5, 330.5, 0.},
 24 -> {643.872, 319.37, 0.}, 
 25 -> {794.571, 405.533, 0.},
 26 -> {415.864, 397.252, 0.}, 
 27 -> {624.794, 369.389, 0.},
 28 -> {488.5, 276.5, 0.}}

你可以做距离变换。 将生成的图像乘以骨架。看一个例子。将骨架分解成多个段并对这些段进行平均。这将是平均线宽。 Matlab/Octave代码:

a=imread('IW.png');
bw=im2bw(a, 0.1);
skeleton=bwmorph(bw, 'skel', Inf);
D = bwdist(~bw);
imagesc(D.*single(skeleton));

或者这个 Matlab/Octave 代码:

a=imread('IW.png');
bw=im2bw(a, 0.1);
skeleton=bwmorph(bw, 'skel', Inf);
branchpoints=bwmorph(skeleton, 'branchpoints');
se=strel('disk', 3);
branchpoints=imdilate(branchpoints,se);
segments=skeleton>branchpoints;
segments=bwareaopen(segments, 8);
stats = regionprops(segments,'Centroid', 'PixelIdxList');
centroids = cat(1, stats.Centroid);
D = bwdist(~bw);
hold on
%imagesc(D.*single(skeleton))
imshow(a)
for i=1:numel(stats)
    m(i)=mean(D(stats(i).PixelIdxList));
    text(centroids(i,1),centroids(i,2), num2str(m(i)), 'Color','blue');
end

结果: