我有一组数据点:
(x1, y1) (x2, y2) (x3, y3) ... (xn, yn)
采样点的数量可以是数千个。我希望用最少(假设30)的点集尽可能准确地表示同一条曲线。我想捕捉尽可能多的拐点。但是,我对表示数据的允许点数有一个硬性限制。
实现相同目标的最佳算法是什么?有没有什么免费的软件库可以帮上忙?
PS:我试图实现基于相对斜率差异的点消除,但这并不总是导致最好的数据表示。
发布于 2010-04-12 16:46:27
您正在搜索插值算法。如果你的一组点是数学意义上的函数(所有的x值都是相互分离的),那么你可以进行多项式插值,或者它们分布在二维平面上,那么你可以使用bezier曲线。
发布于 2016-01-17 21:52:06
多年后的延迟答案:
function DouglasPeucker(PointList[], epsilon)
// Find the point with the maximum distance
dmax = 0
index = 0
end = length(PointList)
for i = 2 to ( end - 1) {
d = perpendicularDistance(PointList[i], Line(PointList[1], PointList[end]))
if ( d > dmax ) {
index = i
dmax = d
}
}
// If max distance is greater than epsilon, recursively simplify
if ( dmax > epsilon ) {
// Recursive call
recResults1[] = DouglasPeucker(PointList[1...index], epsilon)
recResults2[] = DouglasPeucker(PointList[index...end], epsilon)
// Build the result list
ResultList[] = {recResults1[1...length(recResults1)-1], recResults2[1...length(recResults2)]}
} else {
ResultList[] = {PointList[1], PointList[end]}
}
// Return the result
return ResultList[]
end
它经常被用来简化GPS轨迹和减少航点数量。作为准备,您可能需要对您的点进行排序,以存储列表或数组中相邻的邻近点。
发布于 2010-04-12 16:44:43
这取决于曲线是否必须与每个点相交,还是近似。尝试:
https://stackoverflow.com/questions/2623689
复制相似问题