0

我想测量图像中树枝的厚度。以下是从斐济获得的输出。

在此处输入图像描述

我想计算与每个边缘相关的厚度的平均测量值。我所说的边缘是指存在于任何两个分支点之间的段。

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

图片来源:参考

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

编辑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.}}
4

1 回答 1

1

你可以做距离变换。将生成的图像乘以骨架。看一个例子。将骨架分解成段并在这些段上平均。这将是平均线粗细。Matlab/八度代码:

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

结果: 在此处输入图像描述

于 2020-05-03T14:10:36.763 回答