小编ees*_*ees的帖子

Python - 使用样条线插值 2D 点云

我正在尝试拟合 2D 点云(x 和 y 坐标)。到目前为止,我在 scipy 的插值包方面取得了有限的成功,最值得注意的是UnivariateSpline,它产生了以下(次优)拟合(请忽略颜色): 单变量样条

然而,这显然是错误的包,因为我需要一条可以在抛物线点云边缘附近自行弯曲的最终曲线(因此不再是一维函数)。

例如,然后我阅读了interp2d,但不明白我的z数组是什么。是否有我可能忽略的更好的软件包类别?


更新 1:按照评论中的建议,我使用scipy.interpolate.splprep;重新完成了此操作 我的一般设置是:

from scipy.interpolate import splprep, splev
pts = np.vstack((X.ravel(), Y.ravel)) #X and Y contain my points
(tck, u), fp, ier, msg = splprep(pts, u=None, per=0, k=3, full_output=True) #s = optional parameter (default used here)
print('Spline score:',fp) #goodness of fit flatlines after a given s value (and higher), which captures the default s-value as well 
x_new, y_new = …
Run Code Online (Sandbox Code Playgroud)

python interpolation spline point-clouds

5
推荐指数
1
解决办法
2540
查看次数

标签 统计

interpolation ×1

point-clouds ×1

python ×1

spline ×1