A Practical Review of Uniform B-Splines

Similar documents
Splines. Parameterization of a Curve. Curve Representations. Roller coaster. What Do We Need From Curves in Computer Graphics? Modeling Complex Shapes

Computer Graphics Curves and Surfaces. Matthias Teschner

Fall CSCI 420: Computer Graphics. 4.2 Splines. Hao Li.

Properties of Blending Functions

Lecture IV Bézier Curves

Bézier Splines. B-Splines. B-Splines. CS 475 / CS 675 Computer Graphics. Lecture 14 : Modelling Curves 3 B-Splines. n i t i 1 t n i. J n,i.

Remark. Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 331

08 - Designing Approximating Curves

CS 475 / CS Computer Graphics. Modelling Curves 3 - B-Splines

A MATRIX FORMULATION OF THE CUBIC BÉZIER CURVE

ECE 600, Dr. Farag, Summer 09

Bezier Curves, B-Splines, NURBS

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Interactive Graphics. Lecture 9: Introduction to Spline Curves. Interactive Graphics Lecture 9: Slide 1

Parametric Curves. University of Texas at Austin CS384G - Computer Graphics

Curves and Surfaces. Shireen Elhabian and Aly A. Farag University of Louisville

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Sung-Eui Yoon ( 윤성의 )

2D Spline Curves. CS 4620 Lecture 13

CS130 : Computer Graphics Curves (cont.) Tamar Shinar Computer Science & Engineering UC Riverside

Intro to Curves Week 1, Lecture 2

Surfaces for CAGD. FSP Tutorial. FSP-Seminar, Graz, November

2D Spline Curves. CS 4620 Lecture 18

Intro to Curves Week 4, Lecture 7

CS 536 Computer Graphics Intro to Curves Week 1, Lecture 2

Parametric curves. Brian Curless CSE 457 Spring 2016

CSE 167: Introduction to Computer Graphics Lecture #11: Bezier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2016

(Spline, Bezier, B-Spline)

Lecture 9: Introduction to Spline Curves

Rational Bezier Surface

Derivative. Bernstein polynomials: Jacobs University Visualization and Computer Graphics Lab : ESM4A - Numerical Methods 313

Splines. Connecting the Dots

Parametric curves. Reading. Curves before computers. Mathematical curve representation. CSE 457 Winter Required:

Design considerations

3D Modeling Parametric Curves & Surfaces. Shandong University Spring 2013

3D Modeling Parametric Curves & Surfaces

Computergrafik. Matthias Zwicker Universität Bern Herbst 2016

Spline Notes. Marc Olano University of Maryland, Baltimore County. February 20, 2004

MA 323 Geometric Modelling Course Notes: Day 28 Data Fitting to Surfaces

Natural Quartic Spline

Rational Bezier Curves

Computergrafik. Matthias Zwicker. Herbst 2010

An Introduction to B-Spline Curves

Important Properties of B-spline Basis Functions

Curves. Computer Graphics CSE 167 Lecture 11

(Refer Slide Time: 00:02:24 min)

The Free-form Surface Modelling System

Representing Curves Part II. Foley & Van Dam, Chapter 11

Curve and Surface Basics

Central issues in modelling

Information Coding / Computer Graphics, ISY, LiTH. Splines

Free-Form Deformation (FFD)

Rendering Curves and Surfaces. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

OUTLINE. Quadratic Bezier Curves Cubic Bezier Curves

lecture 10: B-Splines

Computer Graphics. Curves and Surfaces. Hermite/Bezier Curves, (B-)Splines, and NURBS. By Ulf Assarsson

Spline Morphing. CG software practical course in the IWR. Carl Friedrich Bolz. Carl Friedrich Bolz

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

Cubic spline interpolation

Element Quality Metrics for Higher-Order Bernstein Bézier Elements

SPLITTING THE CUBIC UNIFORM B-SPLINE CURVE

CSE 167: Introduction to Computer Graphics Lecture 12: Bézier Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

CAGD PACKAGE FOR MATHEMATICA AND ITS USAGE IN THE TEACHING

Advanced Graphics. Beziers, B-splines, and NURBS. Alex Benton, University of Cambridge Supported in part by Google UK, Ltd

Parametric Surfaces. Michael Kazhdan ( /657) HB , FvDFH 11.2

CSE 167: Introduction to Computer Graphics Lecture #13: Curves. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Freeform Curves on Spheres of Arbitrary Dimension

Quasi-Quartic Trigonometric Bézier Curves and Surfaces with Shape Parameters

Quadratic and cubic b-splines by generalizing higher-order voronoi diagrams

B-Splines and NURBS Week 5, Lecture 9

CS 450 Numerical Analysis. Chapter 7: Interpolation

MA 323 Geometric Modelling Course Notes: Day 21 Three Dimensional Bezier Curves, Projections and Rational Bezier Curves

Objects 2: Curves & Splines Christian Miller CS Fall 2011

Lecture 2.2 Cubic Splines

Figure 5.1: Spline and ducks.

Roadmap for tonight. What are Bezier curves (mathematically)? Programming Bezier curves (very high level view).

See the course website for important information about collaboration and late policies, as well as where and when to turn in assignments.

Spline Methods Draft. Tom Lyche and Knut Mørken

Until now we have worked with flat entities such as lines and flat polygons. Fit well with graphics hardware Mathematically simple

Spline Methods Draft. Tom Lyche and Knut Mørken. Department of Informatics Centre of Mathematics for Applications University of Oslo

Spline Methods Draft. Tom Lyche and Knut Mørken

Supervised vs. Unsupervised Learning

A generalized conversion matrix between non-uniform B-spline and Bézier representations with applications in CAGD

Intro to Modeling Modeling in 3D

Justify all your answers and write down all important steps. Unsupported answers will be disregarded.

A general matrix representation for non-uniform B-spline subdivision with boundary control

CSC 305 More Modelling

CS-184: Computer Graphics. Today

Interpolation by Spline Functions

Assessing the Quality of the Natural Cubic Spline Approximation

INF3320 Computer Graphics and Discrete Geometry

Approximation of 3D-Parametric Functions by Bicubic B-spline Functions

February 23 Math 2335 sec 51 Spring 2016

EECS 556 Image Processing W 09. Interpolation. Interpolation techniques B splines

Introduction to Geometry. Computer Graphics CMU /15-662

Need for Parametric Equations

Four equations are necessary to evaluate these coefficients. Eqn

CS-184: Computer Graphics

Distance Functions 1

15.10 Curve Interpolation using Uniform Cubic B-Spline Curves. CS Dept, UK

Transcription:

A Practical Review of Uniform B-Splines Kristin Branson A B-spline is a convenient form for representing complicated, smooth curves. A uniform B-spline of order k is a piecewise order k Bezier curve, and is C k -continuous (i.e. the 0 th through (k ) th derivatives are continuous). The form of a B-spline is in general chosen because it is easy to manipulate, not because it is the solution to an optimization problem, like smoothing splines. B-splines are particularly easy to manipulate because they have local control: parameters of the B-spline only affect a small part of the entire spline. This review includes the details of B-splines that I find relevant for practically understanding and implementing B-splines. Bezier Curves A Bezier curve of order k is defined by k control points, and is a degree k polynomial. A Bezier curve is a smooth interpolation of these k control points. A linear Bezier curve (order ) is a linear interpolation of its two control points, p 0 and p : p 0 (s) = ( s)p 0 + sp, defined for 0 s. A quadratic Bezier curve (order 3) is a linear interpolation between the linear interpolation of control points p 0 and p and the linear interpolation of control points p and p : p 0 (s) = ( s)p 0 + sp, p (s) = ( s)p + sp p 0 (s) = ( s)p 0 (s) + sp (s) = ( s)[( s)p 0 + sp ] + s[( s)p + sp ] = ( s) p 0 + s( s)p + s p This method of interpolating between interpolations is called the decasteljau algorithm, and can be generalized to any order k by iterating the equation p ij = ( s)p i,j + sp i+,j. Iterations must be carried out in order of increasing j, from j = 0 to k. The base case is just the control point, p i0 = p i. For a given j, the iterations must be carried out for i = 0,..., k j, in any order. Let s see the decasteljeau algorithm for the popular cubic Bezier curve (order 4), with control points p 0, p, p, and p 3. The linear interpolation: p 0 (s) = ( s)p 0 + sp, p (s0 = ( s)p + sp p (s) = ( s)p + sp 3 The quadratic interpolation: p 0 (s) = ( s)p 0 (s) + sp (s) = ( s) p 0 + s( s)p + s p Similarly, The cubic interpolation: p (s) = ( s) p + s( s)p + s p 3. p 03 (s) = ( s)p 0 (s) + sp (s) = ( s)[( s) p 0 + s( s)p + s p ] + s[( s) p + s( s)p + s p 3 ] = ( s) 3 p 0 + 3s( s) p + 3s ( s)p + s 3 p 3

A Bezier curve can be expressed in terms of basis functions b ij (s) so that k p 0,k (s) = b i,k (s)p i. These basis functions are the Bernstein polynomials, defined recursively by b ij (s) = ( s)b i,j (s) + sb i,j (s) with base cases b 00 (s) =, b ij (s) = 0 if i < 0 or i > j. We can verify this for the cubic Bezier curve: p 03 (s) = b 03 (s)p 0 + b 3 (s)p + b 3 (s)p + b 33 (s)p 3 = [( s)b 0 (s) + sb, (s)]p 0 + [( s)b (s) + sb 0 (s)]p +[( s)b (s) + sb (s)]p + [( s)b 3 (s) + sb (s)]p 3 = ( s)b 0 (s)p 0 + [( s)b (s) + sb 0 (s)]p +[( s)b (s) + sb (s)]p + sb (s)p 3 = ( s)[( s)b 0 (s) + sb, (s)]p 0 + {( s)[( s)b (s) + sb 0 (s)] + s[( s)b 0 (s) + sb, (s)]}p +{( s)[( s)b (s) + sb (s)] + s[( s)b (s) + sb 0 (s)]}p + s[( s)b (s) + sb (s)]p 3 = ( s) b 0 (s)p 0 + [( s) b (s) + s( s)b 0 (s)]p +[s( s)b (s) + s b 0 (s)]p + s b (s)p 3 = ( s) [( s)b 00 (s) + sb,0 (s)]p 0 + {( s) [( s)b 0 (s) + sb 00 (s)] + s( s)[( s)b 00 (s) + sb,0 (s)]}p +{s( s)[( s)b 0 (s) + sb 00 (s)] + s [( s)b 00 (s) + sb,0 (s)]}p + s [( s)b 0 (s) + sb 00 (s)]p 3 = ( s) 3 p 0 + [s( s) + s( s) ]p + [s ( s) + s ( s)]p + s 3 p 3 = ( s) 3 p 0 + 3s( s) p + 3s ( s)p + s 3 p 3 The closed form equation for the basis functions is: This basis has some nice properties: b ij (s) = j! i!(j i)! si ( s) j i. Partition of unity: for all 0 s. j b ij (s) =, b ij (s) 0 Affine Invariance: any linear transformation of p i results in a linear transformation of the Bezier curve. The Bezier curve is tangent to the first and last segments of the control polygon. B-Splines are Piecewise Bezier Curves A B-spline of order k is a piecewise order k Bezier curve, and is C k -continuous. Because of the continuity requirements at each breakpoint between Bezier curve pieces, only one control point of the second Bezier curve piece is free. Thus, L + k control points define L curve pieces for an open spline (only L control points are needed to define L curve pieces of a closed spline). We generalize the Bezier basis functions to the B-spline basis functions: B ij (s) = s i j B i,j (s) + i + j s B i+,j (s) j

with base cases B i (s) = for i = 0,..., L. The equation for a B-spline is then B i3 (s) = { if i u < i + L p 0,k (s) = B i,k (s)p i. For the special case of the cubic B-spline (k = 4), the basis functions are 6 (s i)3 if i s < i + 6 [ 3(s i )3 + 3(s i ) + 3(s i ) + ] if i + s < i + 6 [3(s i )3 6(s i ) + 4] if i + s < i + 3 6 [ (s i 3)]3 if i + 3 s < i + 4 The B-spline basis functions also have some nice properties: Local support: Each curve piece is only a function of the four closest control points. The basis functions are translates of each other: The curve is C k continuous. The basis functions are a partition of unity. Affine invariance. B ik (s) = B 0k (s i). 3 A Convenient Representation Because of the local support property, we can rewrite the equation for a cubic B-spline as p(s) = 6 [ ( (s i)) 3 p i 3 + [3(s i) 3 6(s i) + 4]p i + [ 3(s i) 3 + 3(s i) + 3(s i) + ]p i + (s i) 3 p i ], where i s < i +. A similar computation can be made for any k. This can be written in matrix notation as p i 3 p(s) = [ s s s 3 ]B i p i p i, p i again where i s < i +. In this equation, 6 i3 6 (3i3 + 3i 3i + ) i3 i + 3 i (i + )3 B i = i (3i )(i + ) (3i + 4i) (i + ) i (3i + ) (3i + ) (i + ) 6 We can also include the placement matrix G i : p(s) = [ s s s 3 ]B i G i p, 6. 3

where p is the vector of control points, For an open spline G i [m, n] = p = p 0. p n. { if n = i + m 3 For a closed spline, the placement matrix is similar: { if n = i + m 3 3 modl G i [m, n] = This form is convenient for taking derivatives or integrals w.r.t. s, since the only term in this equation that depends on s is the first row vector. This simplifies calculations like computing the curve tangents and normals, or the curve area, centroid, and variance. 4 Fitting a B-Spline to Data Points Suppose we want to find the set of control points P that best interpolates a set of data points {(s i, x i )} N i=. We use best in the least-squares sense, i.e. we want to find P that minimizes: h[p] = N (x i p(s i ; P)). To solve this problem, we can write the function p(s i ; P) in vector form: It must then be that A s is a N L matrix such that i= P(s; P) = A s P. P(s i ; P) = A s (i, :)P = L B j,k (s i )p j j=0 Thus, entry A s (i, j) = B j,k (s i ). Notice that each row of A s will be nonzero for at most four consecutive entries (exactly four for a closed B-spline). Given this vector notation for P(s i ; P), we can write the optimization as P = min trace[(x A sp) (X A s P)]. P To find the minimizing P, we can take the derivative w.r.t. P and set it to 0, then solve for P. This results in P = (A s A s ) A s X. 5 Matlab Implementations I have implemented a number of B-spline functions in Matlab. To get started with B-splines, I recommend playing with the function input spline.m. This function allows the user to input a closed B-spline on top of an image. The most interesting function called by input spline.m is fit closed b spline.m. This function fits a closed B-spline to the input data points, as described in Section 4. This function can be easily extended to open splines, if one wishes. I have also implemented some basic functions for dealing with cubic, uniform B-splines. The functions evaluate spline.m and evaluate spline curve.m evaluate the B-spline (D and D, respectively) defined by the input control points 4

at the input locations. These both use the convenient representation discussed in Section 3. The B i and G i matrices discussed in section 3 are created using the function setup cubic splines.m, which sets up the matrices for the desired number of curve pieces. The functions evaluate spline prime.m and evaluate normal.m compute the tangents and normals of the B-spline at the input locations, again using the representation of Section 3. The function transform coefs.m takes advantage of the affine invariance of the B-spline basis functions, and applies a translation, scaling, and rotation to an input B-spline. Note that the functions described in this paragraph have an interface that allows multiple sets of control points, defining multiple B-splines, be input and evaluated at once. This is because my implementation is designed for tracking contours using particle filtering. [] References [] S. Buss. 3-D Compute Graphics. Cambridge University Press, New York, 003. [] E. Demidov. An interactive introduction to splines website: http://www.ibiblio.org/e-notes/splines/intro.htm, 004. [3] T. Hastie, R. Tibshirani, and J. Friedman. The Elements of Statistical Learning. Springer Series in Statistics. Springer Verlag, Basel, 00. 5