我有一个由37817个3D顶点(data here)组成的点云。对于每个顶点i
,我计算15mm(NeighborVert{i}
)以内的所有邻居。使用通过sphereFit
(source code)的这些邻居适合一个球体。计算每个标识的邻居到球体表面的平方距离,记为epsilon{i}(j)
,以量化每个邻居到拟合球体的残差。然后,我对epsilon{i}
中j
内的所有值求和,并将结果存储为E(i)
,它测量球面对于顶点i
的邻域的总体拟合。以上过程是通过下面的MATLAB代码实现的:
T = readtable("<path>\Vertices.xlsx", 'ReadVariableNames',false);
Vertices = table2array(T);
Vertfmt = pointCloud(Vertices);
radius = 15;
for i = 1:size(Vertices, 1)
[NeighborIndex{i}] = findNeighborsInRadius(Vertfmt, Vertices(i,:), radius);
NeighborVert{i} = Vertices(NeighborIndex{i},:);
[center(i, :), r(i)] = sphereFit(NeighborVert{i});
for j = 1:length(NeighborIndex{i})
epsilon{i}(j) = abs((NeighborVert{i}(j, 1) - center(i, 1))^2 + (NeighborVert{i}(j, 2) - center(i, 2))^2 + (NeighborVert{i}(j, 3) - center(i, 3))^2 - r(i)^2);
E(i) = sum(epsilon{i}(j));
end
end
epsilon{i}
应该包含多个值,因为存储了顶点i
的所有邻居到拟合球体表面的平方距离。但是,我的结果表明,每个epsilon{i}
仅包含1个值。如何在每次迭代中保存epsilon{i}(j)
中的所有epsilon{i}
?
此外,我对E(i)
的代码是否在所有j
的{{1}}上正确汇总?