[英]Fit a least-square mean plane to point cloud data in Matlab
I am really struggling to fit a mean plane to point cloud data in Matlab (least square). 我真的很难在Matlab(最小二乘法)中使用平均平面来指向云数据。 I've tried numerous other approaches as exemplified on this page, but get the same mean plane as in the image, which obviously is terribly wrong. 我已经尝试了许多其他方法,如本页所示,但是获得与图像中相同的平均平面,这显然是非常错误的。 Do you have any idea what may be wrong? 你知道什么可能是错的吗?
load('xyz.mat'); %//load the variable 'a' that is 44005x3 in size
x = a(:,1);
y = a(:,2);
z = a(:,3);
%//Calculate coeffs for a mean plane for points x,y,z
%//eq: xh(1) xh(2)*x + xh(3)y + - z = 0
[X,Y] = meshgrid(min(x):10:max(x),min(y):10:max(y));
A = [ones(length(x),1) x y ];
xh = A'*A\(A'*z);
Zp = X.*(xh(2)) + Y.*xh(3) + xh(1);
%//plot mean plane
mesh(X,Y,Zp,'EdgeColor','Black');
hold on;
%//plot pointcloud
pcshow(a)
hold off;
Try using the pcfitplane
function. 尝试使用pcfitplane
功能。 It does a robust fit using RANSAC. 它使用RANSAC做得非常合适。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.