如何减少 (x,y) 数据中的点数
我有一组数据点:
(x1, y1) (x2, y2) (x3, y3) ... (xn, yn)
样本点的数量可以是数千个。我想用最少的(假设 30 个)点集尽可能准确地表示相同的曲线。我想捕捉尽可能多的拐点。但是,我对表示数据的允许点数有严格限制。
实现相同目标的最佳算法是什么?有没有可以提供帮助的免费软件库?
PS:我尝试实现基于相对斜率差的点消除,但这并不总是产生最佳的数据表示。
I have a set of data points:
(x1, y1) (x2, y2) (x3, y3) ... (xn, yn)
The number of sample points can be thousands. I want to represent the same curve as accurately as possible with minimal (lets suppose 30) set of points. I want to capture as many inflection points as possible. However, I have a hard limit on the number of allowed points to represent the data.
What is the best algorithm to achieve the same? Is there any free software library that can help?
PS: I have tried to implement relative slope difference based point elimination, but this does not always result in the best possible data representation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您正在寻找插值算法。您的点集是数学意义上的函数(所有 x 值彼此分离),那么您可以进行多项式插值,或者它们分布在 2d 平面上,那么您可以使用贝塞尔曲线。
You are searching for an interpolation algorithm. Is your set of points a function in a mathematical sense (all x values are disjunct from each other) then you can go for a polynomial interpolation, or are they distributed over the 2d plane, then you could use bezier curves.
多年后迟到的答复:
查看Douglas-Peucker 算法 :
它经常用于简化 GPS 轨迹并减少航点数量。作为准备,您可能需要对点进行排序,以将相邻点存储在列表或数组中。
Late answer after years:
Have a look at the Douglas-Peucker algorithm:
It is frequently used to simplify GPS tracks and reduce the number of waypoints. As a preparation, you may have to sort your points to store neighbour points adjacent in your list or array.
这取决于您的曲线是否与每个点相交或者它是近似值。尝试:
it depends on must your curve intersect each point or it is approximation. Try: