The POLY_2D function performs polynomial warping of images. This function performs a geometrical transformation in which the resulting array is defined by:
g [x, y] = f [x', y'] = f [a [x, y], b [x, y]]
where g [ x , y ] represents the pixel in the output image at coordinate ( x , y ), and f [ x ', y '] is the pixel at ( x ', y ') in the input image that is used to derive g [ x , y ]. The functions a ( x , y ) and b ( x , y ) are polynomials in x and y of degree N , whose coefficients are given by P and Q , and specify the spatial transformation:
Either the nearest neighbor or bilinear interpolation methods can be selected.
A two-dimensional array of any basic type except string. The result has the same type as Array .
P and Q are arrays containing the polynomial coefficients. Each array must contain ( N +1) 2 elements (where N is the degree of the polynomial). For example, for a linear transformation, P and Q contain four elements and can be a 2 x 2 array or a 4-element vector. P i,j contains the coefficient used to determine x' , and is the weight of the term x j y i . The POLYWARP procedure can be used to fit (x', y') as a function of (x, y) and determines the coefficient arrays P and Q .
Set this argument to a 1to perform bilinear interpolation. Set this argument to 2 to perform cubic convolution interpolation (as described under the CUBIC keyword, below). Otherwise, the nearest neighbor method is used. For the linear case, ( N =1), bilinear interpolation requires approximately twice as much time as does the nearest neighbor method.
Set this keyword to a value between -1 and 0 to use the cubic convolution interpolation method with the specified value as the interpolation parameter. Setting this keyword equal to a value greater than zero specifies a value of -1 for the interpolation parameter. Park and Schowengerdt (see reference below) suggest that a value of -0.5 significantly improves the reconstruction properties of this algorithm. Note that cubic convolution interpolation works only with one- and two-dimensional arrays.
Cubic convolution is an interpolation method that closely approximates the theoretically optimum sinc interpolation function using cubic polynomials. According to sampling theory, details of which are beyond the scope of this document, if the original signal, f , is a band-limited signal, with no frequency component larger than w 0 , and f is sampled with spacing less than or equal to 1/2 w 0 , then f can be reconstructed by convolving with a sinc function: sinc ( x ) = sin ( p x ) / ( p x ).
In the one-dimensional case, four neighboring points are used, while in the two-dimensional case 16 points are used. Note that cubic convolution interpolation is significantly slower than bilinear interpolation.
Rifman, S.S. and McKinnon, D.M., "Evaluation of Digital Correction Techniques for ERTS Images; Final Report", Report 20634-6003-TU-00, TRW Systems, Redondo Beach, CA, July 1974.
S. Park and R. Schowengerdt, 1983 "Image Reconstruction by Parametric Cubic Convolution", Computer Vision, Graphics & Image Processing 23, 256.
Some simple linear (degree one) transformations are:
POLY_2D is often used in conjunction with the POLYWARP procedure to warp images. Create and display a simple image by entering:
A = BYTSCL(SIN(DIST(250)), TOP=!D.TABLE_SIZE) & TV, A
Set up the arrays of original points to be warped by entering:
Set up the arrays of points to be fit by entering:
Use POLYWARP to generate the P and Q inputs to POLY_2D by entering:
POLYWARP, XI, YI, XO, YO, 1, P, Q
To perform an image warping based on P and Q, enter:
Display the new image by entering:
Images can also be warped over irregularly gridded control points using the WARP_TRI procedure.