Matlab - 点云数据的曲线拟合

3

这个标签为什么是STL,因为STL是特定于C++的? - templatetypedef
@templatetypedef:我认为他们指的是 *.stl 文件类型-一种用于三角形面的简单几何文件格式:http://en.wikipedia.org/wiki/STL_%28file_format%29。 - Darren Engwirda
1个回答

3
一种方法是最小二乘曲线拟合。您需要拟合一个参数化曲线 [x(t), y(t)],而不是一个简单的曲线 y(x)。根据您的链接,看起来您正在尝试拟合一个简单的曲线 y(x)。有一个方便的最小二乘样条拟合工具 SPLINEFIT 可以从 MATLAB 文件交换 这里 下载。使用此工具,以下是一个简单的示例,演示如何使用最小二乘样条拟合将平滑曲线拟合到一组嘈杂的数据中。在这种情况下,我生成了 10 个随机扰动的圆形数据集,然后以最小二乘方式对数据进行了 5 阶样条拟合。 enter image description here
function spline_test

%% generate a set of perturbed data sets for a circle
   xx = [];
   yy = [];
   tt = [];
   for iter = 1 : 10
   %% random discretisation of a circle
      nn = ceil(50 * rand(1))
   %% uniform discretisation in theta
      TT = linspace(0.0, 2.0 * pi, nn)';
   %% uniform discretisation
      rtemp = 1.0 + 0.1 * rand(1);
      xtemp = rtemp * cos(TT);
      ytemp = rtemp * sin(TT);
   %% parameterise [xtemp, ytemp] on the interval [0,2*pi]
      ttemp = TT;
   %% push onto global arrays
      xx = [xx; xtemp];
      yy = [yy; ytemp];
      tt = [tt; ttemp];    
   end

%% sample the fitted curve on the interval [0,2*pi]
   ts = linspace(0.0, 2.0 * pi, 100);

%% do the least-squares spline fit for [xx(tt), yy(tt)]
   sx = splinefit(tt, xx, 5, 'p');
   sy = splinefit(tt, yy, 5, 'p');

%% evaluate the fitted curve at ts
   xs = ppval(sx, ts);
   ys = ppval(sy, ts);

%% plot data set and curve fit
   figure; axis equal; grid on; hold on;
   plot(xx, yy, 'b.');
   plot(xs, ys, 'r-');

end      %% spline_test()

你的数据显然比这个更复杂,但这可能会让你有所启发。

希望这可以帮到你。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接