B-spline

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In the mathematical subfield of numerical analysis, a B-spline, or Basis spline, is a spline function that has minimal support with respect to a given degree, smoothness, and domain partition. Any spline function of given degree can be expressed as a linear combination of B-splines of that degree. Cardinal B-splines have knots that are equidistant from each other. B-splines can be used for curve-fitting and numerical differentiation of experimental data.

In the computer-aided design and computer graphics, spline functions are constructed as linear combinations of B-splines with a set of control points.

Introduction[edit]

B-splines were investigated as early as the nineteenth century by Nikolai Lobachevsky. The term "B-spline" was coined by Isaac Jacob Schoenberg[1] and is short for basis spline.[2] A spline function is a piecewise polynomial function of degree k in a variable x. The places where the pieces meet are known as knots. The number of knots must be equal to, or greater than k+1. Thus the spline function has limited support. The key property of spline functions is that they are continuous at the knots. Some derivatives of the spline function may also be continuous, depending on whether the knots are distinct or not. A fundamental theorem states that every spline function of a given degree, smoothness, and domain partition, can be uniquely represented as a linear combination of B-splines of that same degree and smoothness, and over that same partition.

Definition[edit]

Cardinal quadratic B-spline. 1st.derivative in magenta
Cardinal cubic B-spline. 1st.derivative in magenta
Cardinal quartic B-spline. 2nd.derivative in red

A B-spline is a piecewise polynomial function of degree k in a variable x. It is defined over a range t 0xtm, tm - t 0 = k+1. The points where x = t j are known as knots or break-points. The number of internal knots is equal to the degree of the polynomial. The knots must be in ascending order. The number of knots is the minimum for the degree of the B-spline, which has a non-zero value only in the range between the first and last knot. Each piece of the function is a polynomial of degree k between and including adjacent knots. A B-spline is a continuous function at the knots.[note 1] When all internal knots are distinct its derivatives are also continuous up to the derivative of degree k-1. If internal knots are coincident at a given value of x, the continuity of derivative order is reduced by 1 for each additional knot.

For any given set of knots, the B-spline is unique, hence the name, B being short for Basis. The usefulness of B-splines lies in the fact that any spline function of degree k on a given set of knots can be expressed as a linear combination of B-splines.

S_{k,t}(x) =\sum_i \alpha_i B_{i,k,t}(x)

This follows from the fact that all pieces have the same continuity properties, within their individual range of support, at the knots.[3]

Expressions for the polynomial pieces can be derived by means of a recursion formula[4]

B_{j,1}(x) := \left\{
\begin{matrix} 
1 & \mathrm{if} \quad t_j \leq x < t_{j+1} \\
0 & \mathrm{otherwise} 
\end{matrix}
\right.
B_{i,k}(x) := \frac{x - t_i}{t_{i+k-1} - t_i} B_{i,k-1}(x) + \frac{t_{i+k} - x}{t_{i+k} - t_{i+1}} B_{i+1,k-1}(x).[5]

This relation leads directly to the FORTRAN-coded algorithm BSPLV which generates values of the B-splines of order k at x.[6] The following scheme illustrates how each piece of degree k is a linear combination of the pieces of B-splines of degree k-1 to its left.


\begin{matrix}
& & 0\\
 &0 & \\
0& &B_{i-2,3}\\
 &B_{i-1,2}& \\
B_{i,1}& &B_{i-1,3}\\
 &B_{i,2}& \\
0& &B_{i,3}\\
 &0& \\
& & 0\\
\end{matrix}

Application of the recursion formula with the knots at 0, 1, 2, and 3 gives the pieces of the uniform B-spline of degree 2

B_1=x^2/2 \qquad 0 \le x \le 1
B_2=(-2x^2+6x-3)/2 \qquad 1 \le x \le 2
B_3=(3-x)^2/2 \qquad 2 \le x \le 3

These pieces are shown in the diagram. The continuity property of a quadratic spline function and its first derivative at the internal knots are illustrated, as follows

\mbox{At x=1}, B_1=B_2=0.5; \frac{dB_1}{dx}=\frac{dB_2}{dx}=1
\mbox{At x=2}, B_2=B_3=0.5; \frac{dB_2}{dx}=\frac{dB_3}{dx}=-1

The second derivative of a spline function of degree 2 is discontinuous at the knots.

\frac{d^2B_1}{dx^2}=1, \frac{d^2B_2}{dx^2}=-2,\frac{d^2B_3}{dx^2}=1,

Faster variants of the de Boor algorithm have been proposed but they suffer from comparatively lower stability.[7][8]

Cardinal B-spline[edit]

A cardinal B-spline has a constant separation, h, between knots. The cardinal B-splines for a given degree k are just shifted copies of each other. They can be obtained from the simpler definition.[9]

B_{i,k,t}(x) = \frac{x-t_i}{h} k[0,\dots,k](. - t_i)^{k-1}_+

The "placeholder" notation is used to indicate that the kth divided difference of the function (t-x)^{k-1}_+ of the two variables t and x is to be taken by fixing x and considering (t - x)^{k-1}_+ as a function of t alone.

See Irwin–Hall distribution#Special cases for algebraic expressions for the cardinal B-splines of degree 1-4.

P-spline[edit]

The term P-spline stands for "penalized B-spline". It refers to using the B-spline representation where the coefficients are determined partly by the data to be fitted, and partly by an additional penalty function that aims to impose smoothness to avoid overfitting.[10]

Derivative expressions[edit]

The derivative of a B-spline of degree k is simply a function of B-splines of degree k-1.[11]

\frac{dB_{i,k}(x)}{dx}=(k-1)\left(\frac{-B_{i+1,k-1}(x)}{t_{i+k}-t_{i+1}}+\frac{B_{i.k-1}(x)}{t_{i+k-1}-t_i}
\right)

This implies that

\frac{d}{dx}\sum_i\alpha_i B_{i,k}=\sum_{i=r-k+2}^{s-1}(k-1)\frac{\alpha_i-\alpha_{i-1}}{t_{i+k-1}-t_i}B_{i,k-1} \ on [t_r.t_s]

which shows that there is a simple relationship between the derivative of a spline function and the B-splines of degree one less.

Curve fitting[edit]

Usually in curve fitting, a set of data points is fitted with a curve defined by some mathematical function. For example common types of curve fitting use a polynomial or a set of exponential functions. When there is no theoretical basis for choosing a fitting function, the curve may be fitted with a spline function composed of a sum of B-splines, using the method of least squares.[12][note 2] Thus, the objective function for least squares minimization is, for a spline function of degree k,

U=\sum_{all x}\left\{ W(x)\left[y(x) - \sum_i \alpha_i B_{i,k,t}(x)\right] \right\}^2

W(x) is a weight and y(x) is the datum value at x. The coefficients \alpha_i are the parameters to be determined. The knot values may be fixed or they too may be treated as parameters.

The main difficulty in applying this process is in determining the number of knots to use and where they should be placed. de Boor suggests various strategies to address this problem. For instance, the spacing between knots is decreased in proportion to the curvature (2nd. derivative) of the data. A few applications have been published. For instance, the use of B-splines for fitting single Lorentzian and Gaussian curves has been investigated. Optimal spline functions of degrees 3-7 inclusive, based on symmetric arrangements of 5, 6, and 7 knots, have been computed and the method was applied for smoothing and differentiation of spectroscopic curves.[13] In a comparable study, the two-dimensional version of the Savitzky-Golay filtering and the spline method produced better results than moving average or Chebyshev filtering.[14]

Computer graphics[edit]

In computer graphics Non-uniform rational B-spline (NURBS curve) is defined by its order, a set of weighted control points, and a knot vector. NURBS curves and surfaces are generalizations of both B-splines and Bézier curves and surfaces, the primary difference being the weighting of the control points which makes NURBS curves "rational". Whereas Bézier curves evolve into only one parametric direction, usually called s or u, NURBS surfaces evolve into two parametric directions, called s and t or u and v.

Surface modelling.svg

By evaluating a Bézier or a NURBS curve at various values of the parameter, the curve can be represented in Cartesian two- or three-dimensional space. Likewise, by evaluating a NURBS surface at various values of the two parameters, the surface can be represented in Cartesian space.

The control points determine the shape of the curve. Typically, each point of the curve is computed by taking a weighted sum of a number of control points. The weight of each point varies according to the governing parameter. For a curve of degree d, the weight of any control point is only nonzero in d+1 intervals of the parameter space. Within those intervals, the weight changes according to a polynomial function (basis functions) of degree d. At the boundaries of the intervals, the basis functions go smoothly to zero, the smoothness being determined by the degree of the polynomial.

The knot vector is a sequence of parameter values that determines where and how the control points affect the NURBS curve. The number of knots is always equal to the number of control points plus curve degree plus one. Each time the parameter value enters a new knot span, a new control point becomes active, while an old control point is discarded.

A NURBS curve takes the following form:[15]

C(u) = \frac {\sum_{i=1}^k {N_{i,n}w_i P}_i} {\sum_{i=1}^k {N_{i,n}w_i}}

Here the notation is as follows. u is the independent variable (instead of x), k is the number of control points, N is a B-spline (used instead of B), n is the polynomial degree, P is a control point and w is a weight. The denominator is a normalizing factor that evaluates to one if all weights are one.

It is customary to write this as

C(u)=\sum_{i=1}^k R_{i,n}(u)P_i

in which the functions

R_{i,n}(u) = {N_{i,n}(u)w_i \over \sum_{j=1}^k N_{j,n}(u)w_j}

are known as the rational basis functions.

A NURBS surface is obtained as the tensor product of two NURBS curves, thus using two independent parameters u and v (with indices i and j respectively):[16]

S(u,v) = \sum_{i=1}^k \sum_{j=1}^l R_{i,j}(u,v) P_{i,j}

with

R_{i,j}(u,v) = \frac {N_{i,n}(u) N_{j,m}(v) w_{i,j}} {\sum_{p=1}^k \sum_{q=1}^l N_{p,n}(u) N_{q,m}(v) w_{p,q}}

as rational basis functions.

See also[edit]

Notes[edit]

  1. ^ Strictly speaking B-splines are usually defined as being left-continuous
  2. ^ de Boor gives FORTRAN routines for least-squares fitting of experimental data.

References[edit]

  • Carl de Boor (1978). A Practical Guide to Splines. Springer-Verlag. ISBN 3-540-90356-9. 
  • Piegl, Les; Tiller, Wayne (1997). The NURBS Book (2nd. edition ed.). Springer. ISBN 3-540-61545-8. 
  1. ^ de Boor, p 114
  2. ^ Gary D. Knott (2000), Interpolating cubic splines. Springer. p. 151
  3. ^ de Boor, p113.
  4. ^ de Boor, p 131.
  5. ^ de Boor, p. 131
  6. ^ de Boor, p. 134.
  7. ^ Lee, E. T. Y. (December 1982). "A Simplified B-Spline Computation Routine". Computing (Springer-Verlag) 29 (4): 365–371. doi:10.1007/BF02246763. 
  8. ^ Lee, E. T. Y. (1986). "Comments on some B-spline algorithms". Computing (Springer-Verlag) 36 (3): 229–238. doi:10.1007/BF02240069. 
  9. ^ de Boor, p 322.
  10. ^ Eilers, P.H.C. and Marx, B.D. (1996). Flexible smoothing with B-splines and penalties (with comments and rejoinder). Statistical Science 11(2): 89-121.
  11. ^ de Boor, p. 138
  12. ^ de Boor, Chapter XIV, p. 235
  13. ^ Gans, Peter; Gill, J. Bernard. "Smoothing and Differentiation of Spectroscopic Curves Using Spline Functions". Applied Spectroscopy 38 (3): 370–376. doi:10.1366/0003702844555511. 
  14. ^ Vicsek, Maria; Neal, Sharon L.; Warner, Isiah M. (1986). "Time-Domain Filtering of Two-Dimensional Fluorescence Data". Applied Spectroscopy 40 (4): 542–548. doi:10.1366/0003702864508773. 
  15. ^ Piegl and Tiller, chapter 4, sec. 2
  16. ^ Piegl and Tiller, chapter 4, sec. 4

External links[edit]