二维曲线近似
这就是我想要做的(最好使用Matlab):
基本上我有几条汽车在十字路口行驶的痕迹。每一个都有噪音,所以我想取所有测量值的平均值,以获得更好的真实路线近似值。换句话说,我正在寻找一种近似曲线的方法,该曲线与所有测量迹线的距离最小(在最小二乘意义上)。
乍一看,这与使用 CurveFitting Toolbox 的 spap2 可以实现的功能非常相似(最小二乘近似部分中的很好的例子此处)。 但这个算法有一些主要缺点:它假设一个函数(每个 x 恰好有一个 y(x)),但我想要的是 2d 中的一条曲线(一个 x 可能有多个 y(x))。当汽车右转或左转超过 90 度时,就会出现问题。 此外,它采用垂直偏移而不是垂直偏移(根据 wolfram 上的定义)。
有人知道如何解决这个问题吗?我想过使用 B 样条曲线并更改节点数和阶数,直到达到一定的拟合质量,但我找不到分析解决此问题的方法或使用 CurveFitting Toolbox 提供的功能。有没有办法在不进行数值优化的情况下解决这个问题?
here is what I want to do (preferably with Matlab):
Basically I have several traces of cars driving on an intersection. Each one is noisy, so I want to take the mean over all measurements to get a better approximation of the real route. In other words, I am looking for a way to approximate the Curve, which has the smallest distence to all of the meassured traces (in a least-square sense).
At the first glance, this is quite similar what can be achieved with spap2 of the CurveFitting Toolbox (good example in section Least-Squares Approximation here).
But this algorithm has some major drawback: It assumes a function (with exactly one y(x) for every x), but what I want is a curve in 2d (which may have several y(x) for one x). This leads to problems when cars turn right or left with more then 90 degrees.
Futhermore it takes the vertical offsets and not the perpendicular offsets (according to the definition on wolfram).
Has anybody an idea how to solve this problem? I thought of using a B-Spline and change the number of knots and the degree until I reached a certain fitting quality, but I can't find a way to solve this problem analytically or with the functions provided by the CurveFitting Toolbox. Is there a way to solve this without numerical optimization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
姆贝克什是对的。为了获得足够的曲线形状灵活性,必须使用参数曲线表示 (x(t), y(t)),而不是显式表示 y(x)。请参阅参数方程。
给定曲线上的 n 个连续点,如果您知道,则为它们分配真实时间;如果您不知道,则仅分配整数 0..n-1。然后使用向量 T, X 和 T, Y 而不是 X, Y 调用 spap2 两次。现在对于任意 t,您将在曲线上得到一个点 (x, y)。
这不会为您提供真正的最小二乘解决方案,但应该足以满足您的需求。
mbeckish is right. In order to get sufficient flexibility in the curve shape, you must use a parametric curve representation (x(t), y(t)) instead of an explicit representation y(x). See Parametric equation.
Given n successive points on the curve, assign them their true time if you know it or just integers 0..n-1 if you don't. Then call spap2 twice with vectors T, X and T, Y instead of X, Y. Now for arbitrary t you get a point (x, y) on the curve.
This won't give you a true least squares solution, but should be good enough for your needs.