2005. 05. 11 2003010482 Mohiuddin Ahmad 2005010207 SUNG-BONG JANG Interpolation II (8.4 SPLINE INTERPOLATION) (8.5 MATLAB’s INTERPOLATION Functions)

Slides:



Advertisements
Similar presentations
Splines and Piecewise Interpolation
Advertisements

Interpolation A method of constructing a function that crosses through a discrete set of known data points. .
By S Ziaei-Rad Mechanical Engineering Department, IUT.
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
Spline Functions – An Elegant View of Interpolation Bruce Cohen David Sklar
Data mining and statistical learning - lecture 6
MATH 685/ CSI 700/ OR 682 Lecture Notes
Selected from presentations by Jim Ramsay, McGill University, Hongliang Fei, and Brian Quanz Basis Basics.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Basis Expansion and Regularization Presenter: Hongliang Fei Brian Quanz Brian Quanz Date: July 03, 2008.
Chapter 18 Interpolation The Islamic University of Gaza
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
1 Curve-Fitting Spline Interpolation. 2 Curve Fitting Regression Linear Regression Polynomial Regression Multiple Linear Regression Non-linear Regression.
Dr. S.M. Malaek Assistant: M. Younesi
CITS2401 Computer Analysis & Visualisation
Curve Fitting: Splines
Computational Methods in Physics PHYS 3437
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
1Notes  Assignment 0 is due today!  To get better feel for splines, play with formulas in MATLAB!
1cs426-winter-2008 Notes  Ian Mitchell is running a MATLAB tutorial, Tuesday January 15, 5pm-7pm, DMP 110 We won’t be directly using MATLAB in this course,
Engineering Computation Curve Fitting: Interpolation 1
Bezier and Spline Curves and Surfaces Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
Lecture 9 Interpolation and Splines. Lingo Interpolation – filling in gaps in data Find a function f(x) that 1) goes through all your data points 2) does.
Bezier and Spline Curves and Surfaces CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
10.1 Gaussian Elimination Method
Chapter 6 Numerical Interpolation
Differential Equations and Boundary Value Problems
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
Scientific Computing Linear and Quadratic Splines.
V. Space Curves Types of curves Explicit Implicit Parametric.
Introduction to Computer Graphics with WebGL
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1.
Splines Vida Movahedi January 2007.
Department of Mechanical Engineering, LSU Session IV MATLAB Tutorials Session IV Mathematical Applications using MATLAB Rajeev Madazhy
June D Object Representation Shmuel Wimer Bar Ilan Univ., School of Engineering.
LINEAR ALGEBRA Matrix analysis Linear equations Eigenvalues and singular values Matrix functions.
41 - 4/24/2000AME 150L1 Solving Engineering Problems, Integrating Equations.
Parametric Surfaces Define points on the surface in terms of two parameters Simplest case: bilinear interpolation s t s x(s,t)x(s,t) P 0,0 P 1,0 P 1,1.
Computers in Civil Engineering 53:081 Spring 2003 Lecture #15 Spline Interpolation.
Jump to first page Chapter 3 Splines Definition (3.1) : Given a function f defined on [a, b] and a set of numbers, a = x 0 < x 1 < x 2 < ……. < x n = b,
Introduction to Numerical Analysis I MATH/CMPSC 455 Splines.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
04/18/02(c) 2002 University of Wisconsin Last Time Hermite Curves Bezier Curves.
CHAP 3 WEIGHTED RESIDUAL AND ENERGY METHOD FOR 1D PROBLEMS
L5 – Curves in GIS NGEN06 & TEK230: Algorithms in Geographical Information Systems by: Sadegh Jamali (source: Lecture notes in GIS, Lars Harrie) 1 L5-
Cubic Spline Interpolation. Cubic Splines attempt to solve the problem of the smoothness of a graph as well as reduce error. Polynomial interpolation.
11/26/02(C) University of Wisconsin Last Time BSplines.
 3.3 Hermite Interpolation Chapter 3 Interpolation and Polynomial Approximation -- Hermite Interpolation Find the osculating polynomial P(x) such that.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
1 Chapter 4 Interpolation and Approximation Lagrange Interpolation The basic interpolation problem can be posed in one of two ways: The basic interpolation.
Interpolation - Introduction
Computational Methods CMSC/AMSC/MAPL 460 Polynomial Interpolation Ramani Duraiswami, Dept. of Computer Science.
1 CHAP 3 WEIGHTED RESIDUAL AND ENERGY METHOD FOR 1D PROBLEMS FINITE ELEMENT ANALYSIS AND DESIGN Nam-Ho Kim.
Chapter 10-2: Curves.
Curve-Fitting Spline Interpolation
Numerical Analysis Lecture 25.
Interpolation.
Interpolation Methods
Chapter 15 Curve Fitting : Splines
Spline Interpolation Class XVII.
Splines and Piecewise Interpolation
Interpolation Methods
MATH 174: Numerical Analysis I
Finite element method.
Splines There are cases where polynomial interpolation is bad
INTERPOLATION For both irregulary spaced and evenly spaced data.
SKTN 2393 Numerical Methods for Nuclear Engineers
Theory of Approximation: Interpolation
Presentation transcript:

Mohiuddin Ahmad SUNG-BONG JANG Interpolation II (8.4 SPLINE INTERPOLATION) (8.5 MATLAB’s INTERPOLATION Functions)

Computer Vision and Pattern Recognition Lab. Mohiuddin Ahmad ID: Computer Vision and Pattern Recognition Lab. Dept. of Computer Science and Engineering Korea University 8.4 : Spline Interpolation

Computer Vision and Pattern Recognition Lab. Spline Interpolation Interpolation qualities  Piecewise polynomial  Want smooth curves  Local control  Local data changes have local effect  Continuous with respect to the data  No wiggling if data changes slightly  Low computational effort Items to be discussed  Piecewise linear interpolation  Piecewise quadratic interpolation  Cubic spline interpolation

Computer Vision and Pattern Recognition Lab. Spline Interpolation Piecewise Linear Interpolation  Simplest form of piecewise polynomial interpolation  Interpolate the data with piecewise linear function

Computer Vision and Pattern Recognition Lab. Piecewise Linear Interpolation Example 8.14 Piecewise Linear Interpolation Function is continuous, but not smooth Figure 8.18 Piecewise linear interpolation

Computer Vision and Pattern Recognition Lab. Piecewise Quadratic Interpolation “Knots”  Where the intervals meet to be the midpoints between the data points where the function values are given Processing  4 data points  Define node points  Spacing between consecutive data points  Relationships:

Computer Vision and Pattern Recognition Lab. Piecewise Quadratic Interpolation We define Since, Equations at the interior nodes [impose continuity condition on the polynomials]

Computer Vision and Pattern Recognition Lab. Piecewise Quadratic Interpolation Equations at the interior nodes [impose continuity condition on the first derivative of the polynomials] We have 6 equations & 8 unknown coefficients  (a 1, a 2, a 3, a 4, b 1, b 2, b 3, b 4 ) Equations for the coefficients at the zero slope conditions at the end points of the interval

Computer Vision and Pattern Recognition Lab. Piecewise Quadratic Interpolation – Example Example : 8: 15 Piecewise interpolating polynomial

Computer Vision and Pattern Recognition Lab. Piecewise Cubic Interpolation Cubic splines → piecewise cubic polynomial Calculation of the coefficients of cubic polynomial Cubic spline function, S(x)

Computer Vision and Pattern Recognition Lab. Piecewise Cubic Interpolation Cubic spline function S(x), n-cubic polynomials P i (x) with coefficients p i,0, p i,1, p i,2, and p i,3 satisfy the following properties: 1. S(x) consists of piecewise cubic (I) 2. Piecewise cubic interpolate the given set of data points (II) 3. Piecewise cubics represent a smooth continuous function (III & IV) 4. Second derivative of the resulting function is continuous (V) S(x) is piecewise cubic, S // (x) is linear on [x 0, x n-1 ]..

Computer Vision and Pattern Recognition Lab. Piecewise Cubic Interpolation Use S // (x i )=a i-1, S // (x i+1 )=a i and h i =x i+1 – x i, we get, Integrating twice will introduce two constant of integration, and the cubic function is From, definition of h i, Integrating P // i (x) twice and using P i (x i ) =y i & P i (x i+1 ) =y i+1 :  Determine the value of b i and c i.

Computer Vision and Pattern Recognition Lab. Piecewise Cubic Interpolation Construction of cubic spline  From property IV, 1 st derivative of P i and P i+1 must agree at x i+1 Natural cubic spline assigns,  2 nd derivative is zero at the endpoints Error in cubic spline interpolation is |S(x) – g(x) |  S(x) : spline interpolation function  g(x) : function that generated the data  Let, h : maximum spacing between node points,  G=max|g (4) (x)|.  Condition: |S(x) – g(x) | < kh 4 G =O(h 4 )

Computer Vision and Pattern Recognition Lab. Choice of Two Additional Conditions End point constraints for a cubic spline Description of the strategyEquation involving a 0 and a n (i) Clamped cubic spline: specify S / (x 0 ), S / (x n ) (ii) Natural cubic spline (iii) Extrapolated S // (x) to the end points (iv) S // (x) is constant near the end points (v)Specify S // (x) at each endpoint

Computer Vision and Pattern Recognition Lab. Example 8.16 Natural Cubic Spline Interpolation Example 8:16

Computer Vision and Pattern Recognition Lab. Example 8.16 Natural Cubic Spline Interpolation Example 8:16 – cont’d

Computer Vision and Pattern Recognition Lab. Matlab function for Natural Cubic Spline Matlab code

Computer Vision and Pattern Recognition Lab. Matlab function for Natural Cubic Spline

Computer Vision and Pattern Recognition Lab. Example 8.17 Runge Function Using tridiagonal solution a1 = , a2 = , a3 = Solving for bi & ci gives b1 = , b2 = , b3 = , b4 = c1 = , c2 = , c3 = , c4 =

Computer Vision and Pattern Recognition Lab. Example 8.17 Runge Function Using tridiagonal solution a1= ; a2 = ; a3= ; a4= ; a5= ; a6= ; a7=1.2221; Consider natural cubic spline, a0 = 0; a8 = 0; Solving for bi & ci gives b1 = , b2 = , b3 = , b4 = , b5 = , b6 = , b7 = , b8 = c1 = , c2 = , c3 = , c4 = , c5 = , c6 = , c7 = , c8 =

Computer Vision and Pattern Recognition Lab. Example 8.17 Runge Function Cubic spline simplifies p1 = *( x ).^3 / *( x) *(x ) ; -1 ≤x ≤ ; p2 = *( x).^3 / * (x ).^3 / *( x) *(x ); ≤x ≤ ; p3 = *( x).^3 / * (x ).^3 / *( x) * (x ) ; ≤x ≤ ; p4 = *( x).^3 / * (x ).^3 / *( x) * (x ); ≤x ≤ 0.0 ; p5 = *( x).^3 / * (x ).^3 / *( x) * (x ) ; 0.0 ≤x ≤ 0.25 ; p6 = *(0.5 - x).^3 / * (x ).^3 / *( x) * (x ) ; 0.25 ≤x ≤ 0.50 ; p7 = *( x).^3 / * (x ).^3 / *( x) * (x ); 0.5 ≤x ≤ 0.75 ; p8 = *( x).^3 / * (x ).^3 / *( x) * (x ) ; 0.75 ≤x ≤ 1.00 ;

Computer Vision and Pattern Recognition Lab. Example 8.18, Chemical Reaction Product Data Chemical reaction of data Conclusion:  Curve is smoother than higher degree polynomial [ Fig. 8.6]  Additional data points do not really improve the appearance of original curve [Fig. 8.5]

Computer Vision and Pattern Recognition Lab. Example: 8.19 Difficult data Data points: Tridiagonal system of equations: Using tridiagonal system a0 = 0 a1= a2= a3= a4= a5= a6= a7= a8 = 0 Solving for bi & ci gives b1 = 0, b2 = , b3 = , b4 = , b5 = , b6 = , b7 = , b8 = c1 = , c2 = , c3 = , c4 = c5 = , c6 = , c7 = , c8 = 0

Computer Vision and Pattern Recognition Lab. Example: 8.19 Difficult data – cont’d Resulting piecewise function made the following polynomial

SUNG-BONG JANG Interpolation II (8.5,MATLAB’s INTERPOLATION Functions)

26 / 7 ■ Interpolation in One-Dimensional MATLAB function : Interp yy = interp1(x,y,xx,method) : interpolates using alternative methods: ‘linear‘ : Linear interpolation (default) 'nearest‘ : Nearest neighbor interpolation ‘cubic’ : Piecewise cubic Hermite interpolation 'spline‘ : Cubic spline interpolation method : linear x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi); plot(x,y,'o',xi,yi)

27 / 7 ■ Interpolation in One-Dimensional method : nearest x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi,’nearest’); plot(x,y,'o',xi,yi) method : cubic x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi,’cubic’); plot(x,y,'o',xi,yi)

28 / 7 ■ Interpolation in One-Dimensional method : spline x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi,’spline’); plot(x,y,'o',xi,yi) Faster methods - the data are given at equally spaced intervals(i.e, x is equally spaced and monotonic): *linear,*cubic,*spline > What is Monotonic ? : A function which is either entirely nonincreasing or nondecreasing.nonincreasingnondecreasing A function is monotonic if its first derivative (which need not be continuous) does notderivative change sign. - the data that are not uniformly spaced : interp1q. - MATLAB ‘plot’ function : linear interpolation

29 / 7 ■ Interpolation in Two Dimensionals Overview -much more difficult than for a single variable. -Defined on a rectangular grid : z(i,j) = f(x(i),y(j)); -Interp2 : three ways in which the interp2 can be used. > ZI = interp2(Z,ntimes) expands Z by interleaving interpolates between every element, working recursively for ntimes. interp2(Z) is the same as interp2(Z,1). > ZI = interp2(Z,XI,YI) assumes that X = 1:n and Y = 1:m, where [m,n] = size(Z). > ZI = interp2(X,Y,Z,XI,YI) returns matrix ZI containing elements corresponding to the elements of XI and YI and determined by interpolation within the two-dimensional function specified by matrices X, Y, and Z.

30 / ZI = interp2(Z,ntimes) - expands the data matrix z by interleaving interpolanes between every element. xx = [x 1, (x 2 + x 2 )/2, x 2,….,(x n-1 + x n-1 )/2, x n ] yy = [y 1, (y 2 + y 2 )/2, y 2,….,(y n-1 + y n-1 )/2, y n ] - zz = interp2(z); zz = interp2(z,k) - Example) x=[2,4], y =[3,5,7], z= x’y, >> interp2(z) ans = >> interp2(z,2) ans = mesh(x,y,z’) * mesh(X,Y,Z) : draws a wireframe mesh with color determined by Z so color is proportional to surface height. If X and Y are vectors, length(X) = n and length(Y) = m, where [m,n] = size(Z). ■ Interpolation in Two Dimensionals

31 / 7 ■ Interpolation in Two Dimensionals ZI = interp2(Z,XI,YI) - the data values beiing interpolated are defined on a mesh given by the vectors x=1:n and y=1:m, where [m,n] = size(z); y gives the rows of the grid and x gives the column - zz = interp2(z’,xx,yy’); - Example) x=[1 2 3] y=[ ] z = x’*y z= Xx= [1, 1.2,2,2.2,3] Yy=[1,1.8,2,4,4.8,5] Zz = interp2(z ’,xx,yy ’ ) = - mesh(xx,yy,zz)

32 / 7 ■ Interpolation in Two Dimensionals ZI = interp2(X,Y,Z,XI,YI), - Interpolation on a Rectangular Grid - Example) x=[2,4], y =[3,5,7], z= x’y, xx=[2, 2.4,2.6,2.8,3,3.5,4] yy = [3,3.5,5,7] zz= interp2(x,y’,z’,xx,yy’) >> zz=interp2(x,y,z',xx,yy') zz = mesh(xx,yy,zz)

33 / 7 ■ Interpolation in Two Dimensionals bilinear interpolation - The value of an interpolated point is a combination of the values of the four closest points. - the form of each rectangular subregion z= a + bx + cy + dxy, Region Rij, four corners : data values: (x i,y j ),(x i,y i+1 ),(x i+1,y J ),(x i+1,y i+1 ), four unknowns : a ij,b ij,c ij,d ij z(i,j) = a ij + b ij x i + c ij y j +d ij x i y j z(i,j+1) = a ij + b ij x i + c ij y j+1 +d ij x i y j+1 z(i+1,j) = a ij + b ij x i+1 + c ij y j +d ij x i+1 y j z(i+1,j+1) = a ij + b ij x i+1 + c ij y j+1 +d ij x i+1 y j+1 - the form of the interpolation methods : ZI = interp2(X,Y,Z,XI,YI,method), method=> ‘cubic’,nearest’,’linear’ - interp3 : VI = interp3(X,Y,Z,V,XI,YI,ZI) interpolates to find VI, the values of the underlying three-dimensional function V at the points in arrays XI,YI and ZI. 3-dimensional - interpn : VI = interpn(X1,X2,X3,...,V,Y1,Y2,Y3,...) interpolates to find VI, the values of the underlying multidimensional function V at the points in the arrays Y1, Y2, Y3, etc. n- dimensional