## POLYWARP

The POLYWARP procedure performs polynomial spatial warping.

Using least squares estimation, POLYWARP determines the coefficients Kx ( i,j ) and Ky ( i,j ) of the polynomial functions:

Kx and Ky can be used as inputs P and Q to the built-in function POLY_2D. This coordinate transformation may be then used to map from Xo, Yo coordinates into Xi, Yi coordinates.

This routine is written in the IDL language. Its source code can be found in the file ``` polywarp.pro``` in the ``` lib``` subdirectory of the IDL distribution.

### Calling Sequence

POLYWARP, Xi, Yi, Xo, Yo, Degree, Kx, Ky

### Arguments

#### Xi, Yi

Vectors of X and Y coordinates to be fit as a function of Xo and Yo.

#### Xo, Yo

Vectors of X and Y independent coordinates. These vectors must have the same number of elements as Xi and Yi .

#### Degree

The degree of the fit. The number of coordinate pairs must be greater than or equal to ( Degree +1) 2 .

#### Kx

A named variable that will contain the array of coefficients for Xi as a function of ( Xo, Y o). This parameter is returned as a ( Degree +1) by ( Degree +1) element array.

#### Ky

A named variable that will contain the array of coefficients for Yi . This parameter is returned as a ( Degree +1) by ( Degree +1) element array.

### Example

The following example shows how to display an image and warp it using the POLYWARP and POLY_2D routines.

Create and display the original image by entering:

A = BYTSCL(SIN(DIST(250)))

TVSCL, A

Now set up the Xi's and Yi's. Enter:

XI = [24, 35, 102, 92]

YI = [81, 24, 25, 92]

Enter the Xo's and Yo's:

XO = [61, 62, 143, 133]

YO = [89, 34, 38, 105]

Run POLYWARP to obtain a Kx and Ky:

POLYWARP, XI, YI, XO, YO, 1, KX, KY

Create a warped image based on Kx and Ky with POLY_2D:

B = POLY_2D(A, KX, KY)

Display the new image:

TV, B