Presentation is loading. Please wait.

Presentation is loading. Please wait.

MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 23.

Similar presentations


Presentation on theme: "MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 23."— Presentation transcript:

1 MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 23

2 MA/CS 375 Fall 20022 Class Exercise Part 1: –Build a function called vandermonde.m which accepts a vector of x values and a polynomial order P –In the function find N=length of x –Function returns a matrix V which is Nx(P+1) and whose entries are: V(n,m) = (x n ) (m-1) Part 2: –Translate this pseudo-code to a Matlab script: –for N=1:5:20 build x = set of N points in [-1,1] build f = exp(x) build xfine = set of 10N points in [-1,1] build Vorig = vandermonde(N-1,x) build Vfine = vandermonde(N-1,xfine) build Finterp = Vfine*(Vorig\f); plot x,f and xfine,Finterp on the same graph –end

3 MA/CS 375 Fall 20023 Runge Phenomenon Theorem 2 (van Loan page 90) –Suppose If(x) is an N-1’th order interpolating polynomial of the function f at N distinct points x 1,x 2,..,x N. If f is N times continuously differentiable on an interval I containing the {x 1,x 2,..,x N } then for any x in I=[a,b]:

4 MA/CS 375 Fall 20024 Runge Phenomenon If we base the interpolant on the equi- spaced points then after some basic math we can show: where M N bounds the N’th derivative

5 MA/CS 375 Fall 20025 Runge Phenomenon If we base the interpolant on the equi-spaced points then after some basic math we can show: where M N bounds the N’th derivative Hence if the N’th derivative is badly behaved this bound suggests the quality of interpolation may decrease with increasing N!!.

6 MA/CS 375 Fall 20026 Example: Runge Phenomenon Use your Vandermonde routine to interpolate the function: for 10,20,30,40,50,60 points on the interval [-1,1] Volunteer to describe what happens

7 MA/CS 375 Fall 20027 Interpolating in Two Directions A picture (e.g. jpeg, tif or gif) is actually an array of pixel values There are a number of ways to represent color on the pixel. 1)gif uses a colormap, indexed by an integer 2)jpeg uses an 8 bit number for each component of red, green and blue

8 MA/CS 375 Fall 20028 Loading an Image in Matlab % read in the three dimensional array pic = imread(‘foo.jpg’); red = pic(:,:,1); green = pic(:,:,2); blue = pic(:,:,3);

9 MA/CS 375 Fall 20029 Double The Resolution In Each Direction Using 4 th order Interpolation

10 MA/CS 375 Fall 200210 Results From Interpolation Notice 600 pixelsNotice 300 pixels

11 MA/CS 375 Fall 200211 Details of Interpolation

12 MA/CS 375 Fall 200212 Details of Interpolation Notice reduced pixellation on new image

13 MA/CS 375 Fall 200213 But Not So Fast

14 MA/CS 375 Fall 200214 Now try 10 th order interpolation

15 MA/CS 375 Fall 200215 Not So Good! Note stripes appearing on new image

16 MA/CS 375 Fall 200216 Close Up of 10 th Order Interpolation Looks quite bad!!!

17 MA/CS 375 Fall 200217 What’s Going On We have divided each line of the picture into non-overlapping sections, containing 10 points each. We have then interpolated the picture values at the 10 points to 20 points on the same section The equispaced points lead to the Runge phenomenon i.e. highly oscillatory interpolants at the ends of each section How can we make this better?

18 MA/CS 375 Fall 200218 Team Exercise ( a little tricky – feel free to use loops) Even for 10+ points the interpolant function is probably going to be ok at the center of the region. 1)build VDM for N points (N even) 2)build weights = VDM\(1;0;0;…;0) 3)load in your jpeg picture 4) now use these weights to build the interpolating values between each given points

19 MA/CS 375 Fall 200219 Nth Order Mid-point Interpolation

20 MA/CS 375 Fall 200220 Nth Order Mid-point Interpolation

21 MA/CS 375 Fall 200221 Nth Order Mid-point Interpolation

22 MA/CS 375 Fall 200222 Summary So we have started to invert general matrix systems to obtain interpolating polyomial coefficients We saw the Runge phenomenon in action when equi-spaced interpolation is used We improved things somewhat by ignoring the interpolating polynomial away from the center of its range.

23 MA/CS 375 Fall 200223 Next Time Using Matlab’s built in interpolation routine Morphing images class project


Download ppt "MA/CS 375 Fall 20021 MA/CS 375 Fall 2002 Lecture 23."

Similar presentations


Ads by Google