三次B样条插值研究
概述
三次样条插值(Cubic Spline Interpolation)简称Spline插值,是通过一系列形值点的一条光滑曲线,数学上通过求解三弯矩方程组得出曲线函数组的过程。B样条的定义就不赘述了:http://blog.csdn.net/tuqu/article/details/4749586
三次b样条插值python实现
import numpy as np
from numpy.lib.function_base import average
from scipy import interpolate
import matplotlib.pyplot as plt
x = [1,3,5,7,9,11,13,15,17,19,21,23]
y = [6.15,6.65,5.83,11.5,13.61,10.29,9.98,10.28,10.16,8.1,6.9,9.62]
tck,u = interpolate.splprep([x,y],k=3,s=0)
num = 1000
u=np.linspace(0,1,num,endpoint=False)
out = interpolate.splev(u,tck)
plt.plot(x, y, 'ro', out[0], out[1], 'b')
plt.legend(['Points', 'Interpolated B-spline', 'True'],loc='best')
plt.show()

浙公网安备 33010602011771号