# 三次B样条曲线拟合算法

OpenCV图像处理 同时被 2 个专栏收录
9 篇文章 1 订阅
6 篇文章 1 订阅

## 1 三次B样条曲线方程

B样条曲线分为近似拟合和插值拟合，所谓近似拟合就是不过特征点，而插值拟合就是通过特征点，但是插值拟合需要经过反算得到控制点再拟合出过特征点的B样条曲线方程。这里会一次介绍两种拟合算法。首先介绍B样条的曲线方程。
B样条曲线的总方程为： P ( t ) = ∑ i = 0 n P i F i , k ( t ) P(t)=\sum_{i=0}^{n} P_{i}F_{i,k}(t) (1)

1.1 三次B样条曲线方程中基函数为：
F i , k ( t ) = 1 k ! ∑ m = 0 k − i ( − 1 ) m ( m k + 1 ) ( t + k − m − j ) k F_{i,k}(t)=\frac{1}{k!}\sum_{m=0}^{k-i}(-1)^{m}\binom{m}{k+1}(t+k-m-j)^k (2)

P ( t ) = P 0 ∗ F 0 , 3 ( t ) + P 1 ∗ F 1 , 3 ( t ) + P 2 ∗ F 2 , 3 ( t ) + P 3 ∗ F 3 , 3 ( t ) P(t)= P_0*F_{0,3}(t)+P_1*F_{1,3}(t)+P_2*F_{2,3}(t)+P_3*F_{3,3}(t) (3)

2019-04-18 更新

F 0 , 3 ( t ) = 1 3 ! ∑ j = 0 3 ( − 1 ) j C 4 j ) ( t + 3 − 0 − j ) 3 F_{0,3}(t)=\frac{1}{3!}\sum_{j=0}^{3}(-1)^{j}C^{j}_{4})(t+3-0-j)^3

= 1 6 [ ( − 1 ) 0 C 4 0 ( t + 3 ) 3 + ( − 1 ) 1 C 4 1 ( t + 2 ) 3 + ( − 1 ) 2 C 4 2 ( t + 1 ) 3 + ( − 1 ) 3 C 4 3 t 3 ] =\frac{1}{6}[(-1)^{0}C^{0}_{4}(t+3)^{3}+(-1)^{1}C^{1}_{4}(t+2)^{3}+(-1)^{2} C^{2}_{4}(t+1)^{3}+(-1)^{3}C^{3}_{4}t^{3}]

= 1 6 ( − t 3 + 3 t 2 − 3 t + 1 ) = 1 6 ( 1 − t ) 3 =\frac{1}{6}(-t^{3}+3t^{2}-3t+1)=\frac{1}{6}(1-t)^{3}

F 1 , 3 ( t ) = 1 3 ! ∑ j = 0 2 ( − 1 ) j C 4 j ) ( t + 3 − 1 − j ) 3 F_{1,3}(t)=\frac{1}{3!}\sum_{j=0}^{2}(-1)^{j}C^{j}_{4})(t+3-1-j)^3

= 1 6 [ ( − 1 ) 0 C 4 0 ( t + 2 ) 3 + ( − 1 ) 1 C 4 1 ( t + 1 ) 3 + ( − 1 ) 2 C 4 2 t 3 ] =\frac{1}{6}[(-1)^{0}C^{0}_{4}(t+2)^{3}+(-1)^{1}C^{1}_{4}(t+1)^{3}+(-1)^{2} C^{2}_{4}t^{3}]

= 1 6 ( 3 t 3 − 6 t 2 + 4 ) =\frac{1}{6}(3t^{3}-6t^{2}+4)

F 2 , 3 ( t ) = 1 3 ! ∑ j = 0 1 ( − 1 ) j C 4 j ) ( t + 3 − 2 − j ) 3 F_{2,3}(t)=\frac{1}{3!}\sum_{j=0}^{1}(-1)^{j}C^{j}_{4})(t+3-2-j)^3

= 1 6 [ ( − 1 ) 0 C 4 0 ( t + 1 ) 3 + ( − 1 ) 1 C 4 1 t 3 =\frac{1}{6}[(-1)^{0}C^{0}_{4}(t+1)^{3}+(-1)^{1}C^{1}_{4}t^{3}

= 1 6 ( − 3 t 3 + 3 t 2 + 3 t + 1 ) =\frac{1}{6}(-3t^{3}+3t^{2}+3t+1)

F 3 , 3 ( t ) = 1 3 ! ∑ j = 0 0 ( − 1 ) j C 4 j ) ( t + 3 − 3 − j ) 3 F_{3,3}(t)=\frac{1}{3!}\sum_{j=0}^{0}(-1)^{j}C^{j}_{4})(t+3-3-j)^3

= 1 6 [ ( − 1 ) 0 C 4 0 t 3 =\frac{1}{6}[(-1)^{0}C^{0}_{4}t^{3}

= 1 6 t 3 =\frac{1}{6}t^{3}

## 3 三次B样条插值拟合

##4 拟合结果

##5 总结

-------------------------------------------------2018-10-30--------------------------------------------

04-23
01-15

01-04
12-20
07-14 3447
07-27 12万+
12-19 4万+
01-13 3万+
01-17 1万+
03-31
06-27
04-04
01-13 1825