The POLYWARP procedure performs polynomial spatial warping.

Using least squares estimation, POLYWARP determines the coefficients Kxi,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.

Examples


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

; Create the original image:
A = BYTSCL(SIN(DIST(250)))
; Get the dimensions of the image
sizeA = SIZE(A, /DIMENSIONS)
xSize=sizeA[0]
ySize=sizeA[1]
; Create the display window
WINDOW, /FREE, XSIZE=xSize*2, YSIZE=ySize, $
   TITLE='POLYWARP Example'
TVSCL, A, 0
; Now set up the Xis and Yis:
XI = [24, 35, 102, 92]
YI = [81, 24, 25, 92]
; Enter the Xos and Yos:
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, 1

Syntax


POLYWARP, Xi, Yi, Xo, Yo, Degree, Kx, Ky [, /DOUBLE] [, STATUS=variable]

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, Yo). 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.

Keywords


DOUBLE

Set this keyword to use double-precision for computations and to return a double-precision result. Explicitly set DOUBLE=0 to ensure the use of single-precision for computations and to return a single-precision result. By default, POLYWARP performs computations in double precision and returns a double-precision result if any of the inputs are double-precision; computations are performed in single precision and the result returned as single-precision if all of the inputs are single-precision.

STATUS

Set this keyword to a named variable to receive the status of the operation. Possible status values are:

Value

Description

0

Successful completion.

1

Singular array (which indicates that the inversion is invalid).

2

Warning that a small pivot element was used and that significant accuracy was probably lost.

Note: If STATUS is not specified, any warning messages will be output to the screen.

Version History


Original

Introduced

See Also


POLY_2D, WARP_TRI