将第 6 行改为:

skel = bwmorph(bw, 'skel', Inf);

修改为:

skel = bwmorph(bw, 'skel', Inf);

% 去除边缘像素 skel(:, [1 end]) = 0; skel([1 end], :) = 0;

% 消除分支条纹 skel_pruned = bwmorph(skel, 'spur', 2);

这样可以去除边缘像素,避免出现在数组边界之外的 true 值,从而修复错误。

读取图像 img = imread7-1tif; 将图像转为二值化矩阵 bw = im2bwimg; 骨架化操作 skel = bwmorphbw skel Inf; 消除分支条纹 skel_pruned = bwmorphskel spur 2; 计算条纹长度 pixel_size = 00595; 空间分辨率为00595纳米像素 lengths = ; for i = 2sizesk

原文地址: https://www.cveoy.top/t/topic/bBaW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录