拟合B样条的“周围”点

时间:2019-05-10 21:33:11

标签: python scipy curve-fitting scikit-image bspline

我有很多表示图像轮廓的点,它们是用scikit-image生成的,看起来像这样

源图像

Source-image

轮廓

Contours

我想在这些点附近拟合一个B样条,以使所得的线最接近图像的轮廓。

c_sample = cts.sample(50)

tck, u = si.splprep(c_sample.values.T, u=None, s=1.0, per=1) 
u_new = np.linspace(u.min(), u.max(), 1000)
x_new, y_new = si.splev(u_new, tck, der=0)

plt.plot(c_sample.values[:,0], c_sample.values[:,1], 'ro')
plt.plot(x_new, y_new, 'b--')
plt.show()

我现在的过程是沿轮廓采样点,并使用scipy splprep和splev来准备和评估曲线。但是生成的样条曲线会在点云周围飞镖,并且不会以整齐的封闭形状填充它们。我使用 per 关键字参数表示形状应封闭

样条拟合

Fitted spline attempt

我正在寻找如何获得所需结果的方向,我的观点是否被用作控制点而不适合?重要的点的顺序是什么?

任何方向或帮助将不胜感激

0 个答案:

没有答案