简体   繁体   English

如何在matlab中的3D点云上拟合曲面?

[英]How can I fit a surface on 3D point cloud in matlab?

I have a point cloud from real world and I want to fit a surface on them and calculate curve of the points(!). 我有一个来自现实世界的点云,我想在它们上面拟合并计算点的曲线(!)。 since points are in the real world so amplitude of difference between x, y and z of points is very large and when I use the code in here I meet the below error in matlab: 由于点在现实世界中,因此点的x,y和z之间的差异幅度非常大,当我在这里使用代码时,我在matlab中遇到以下错误:

Warning: Rank deficient, rank = 2,  tol =   7.9630e-007.

this means that my data are bad conditioned. 这意味着我的数据状况不佳。 a few of my data are: 我的一些数据是:

32512032.3900000    5401399.69000000    347.030000000000
32512033.1400000    5401399.79000000    346.920000000000
32512036.3000000    5401399.62000000    346.840000000000
32512037.3900000    5401399.95000000    346.870000000000
32512034.4800000    5401400                 346.930000000000
32512035.6000000    5401400.05000000    346.950000000000
32512036.6900000    5401400.38000000    346.980000000000
32512037.9600000    5401400.30000000    346.910000000000
32512033.7600000    5401400.42000000    346.880000000000
32512034.8700000    5401400.48000000    346.960000000000

also I use the fit formula in matlab. 我也在matlab中使用了fit公式。

sf = fit( [x, y], z, 'poly23');

and saw the same error: 并看到同样的错误:

Warning: Equation is badly conditioned. Remove repeated data points
         or try centering and scaling.

Is a way that fit a surface or smooth curve on the this type of points? 这种类型的点是否适合曲面或平滑曲线?

Edit 编辑

You can try: 你可以试试:

Centering 定心

%% Centering
oldData = data
center = mean(data);
centerMatrix = ones(size(data,1),1)*center; 
data = data - centerMatrix;         

Scaling 缩放

%% Scaling
scale = max(abs(data));
scaleMatrix = ones(size(data,1),1)*scale;
data = data./scaleMatrix;

But don't forget at the end . 但最后不要忘记。 . .

xx = scale(1)*xx + center(1)
yy = scale(2)*yy + center(2)
zz = scale(3)*zz + center(3)

Centering moves your data to the origin. 居中将数据移动到原点。 Scaling makes the spread more equal, so you don't fit one axis much better than the others. 缩放使得传播更加平等,因此您不能比其他轴更好地适应一个轴。 You have to un-scale and un-center the results afterwards. 之后您必须取消缩放和取消中心结果。

Centering is safe. 定心是安全的。 It should do what you expect and make the result more stable. 它应该做你期望的,并使结果更稳定。 Scaling is not as safe. 缩放不是那么安全。 Make sure it gives you what you want; 确保它能满足你的需求; if centering is enough, you might find that is all you need. 如果居中足够,您可能会发现这就是您所需要的。

In any case, because a point cloud is huge, you should apply this to local patches at a time. 在任何情况下,由于点云很大,您应该一次将其应用于本地补丁。

Why I said "quick and dirty?" 为什么我说“快而又肮脏?” I meant quick as in quick to code. 我的意思是快速编码。 There are many publications that deal with this specifically, and they will run faster. 有许多出版物专门处理这个问题,它们会跑得更快。 Will they produce a better result? 他们会产生更好的结果吗? Well, it depends on what you define as better. 嗯,这取决于你定义的更好。

There isn't a lot of ground-truth data out there for real scanned environments, if you are talking about a scanning laser. 如果您正在谈论扫描激光,那么对于真实的扫描环境,没有很多地面实况数据。 If your point cloud is from something else (stereo vision, structure from motion) there are a lot more data sets you can try. 如果您的点云来自其他东西(立体视觉,运动结构),您可以尝试更多数据集。

Without ground truth, it's hard to say what is "good" and "bad". 没有事实真相,很难说什么是“好”和“坏”。 Usually its pretty obvious. 通常很明显。 But point cloud manipulation is not trivial because of the quantities of data. 但由于数据量的原因,点云操纵并非易事。

Old answer Centering is exactly what I would suggest if you want to try a quick and dirty solution using fit. 如果您想尝试使用fit快速而肮脏的解决方案,那么旧答案中心就是我的建议。 Of course, you can't do this with all of your data at once, but if you select just a few local points (even a few hundred or thousand) and center it first, you should get a much better result. 当然,您不能同时使用所有数据,但如果您只选择几个本地点(甚至几百或几千)并将其居中,那么您应该获得更好的结果。

The problem is occurring because the difference between any two of your points is tiny, but the magnitude of the vectors themselves is quite large. 问题出现了,因为你的任何两点之间的差异很小,但矢量本身的大小非常大。 If you take your data, center it (you can even scale if you like), you can then fit it and reverse the operations. 如果您获取数据,将其居中(如果您愿意,您甚至可以进行缩放),然后您可以适应它并反转操作。 Do this for a chunk at a time. 一次为一块做这件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM