POLY_2D

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 ( 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.

Calling Sequence

Result = POLY_2D( Array, P, Q [, Interp [, Dim x , Dim y ]] )

Arguments

Array

A two-dimensional array of any basic type except string. The result has the same type as Array .

P and Q

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 .

Interp

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.

Dim x

If present, Dim x specifies the number of columns in the output. If omitted, the output has the same number of columns as Array .

Dim y

If present, Dim y specifies the number of rows in the output. If omitted, the output has the same number of rows as Array .

Keywords

CUBIC

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.

For further details see:

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.

MISSING

Specifies the output value for points whose x', y' is outside the bounds of Array . If MISSING is not specified, the resulting output value is extrapolated from the nearest pixel of Array .

Example

Some simple linear (degree one) transformations are:

  • Simple Transformations for Use with POLY_2D

P 0,0 ·

P 1,0 ·

P 0,1 ·

P 1,1 ·

Q 0,0 ·

Q 1,0 ·

Q 0,1 ·

Q 1,1 ·

Effect

0

0

1

0

0

1

0

0

Identity

0

0

0.5

0

0

1

0

0

Stretch X by a factor of 2

0

0

1

0

0

2.0

0

0

Shrink Y by a factor of 2

z

0

1

0

0

1

0

0

Shift left by z pixels

0

1

0

0

0

0

1

0

Transpose

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:

XO = [61, 62, 143, 133]

YO = [89, 34, 38, 105]

Set up the arrays of points to be fit by entering:

XI = [24, 35, 102, 92]

YI = [81, 24, 25, 92]

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:

B = POLY_2D(A, P, Q)

Display the new image by entering:

TV, B, 250, 250

Images can also be warped over irregularly gridded control points using the WARP_TRI procedure.

See Also

POLYWARP