Scott Wilson
COPYRIGHT
Copyright 1991, University of New Mexico. All rights
reserved.
*********************************************************************************
Documentation for avs module vexpwarp
INPUT
image pointer to xvimage structure to be processed
xmap string containing the x map function
ymap string containing the y map function
xca X coordinate of center of action
yca Y coordinate of center of action
OUTPUT
image holds the result of the warp operation. The
output data type is the same as the input
data type.
Return Value: 1 on success, 0 on failure.
DESCRIPTION
vexpwarp is used to alter the spatial properties of an
image by performing a transformation in which the old coor-
dinates of a pixel are mapped to a new location by a pair of
symbolic expressions. The old coordinates, (x,y) are
related to the new coordinates (x',y') by the symbolic
expressions supplied as map functions. These expressions are
evaluates using the xvexpr(3) library, which is also used by
cantata to perform mathematical operations. An example of a
set of mappings is:
For the x' mapping:
4.0*(x#2+y#2)-1/y }
For the y' mapping:
exp(-((y-15)#2)/300) }
The output image is formed by mapping each individual rec-
tangular region in the input image (composed of four neigh-
boring pixels) through the mapping functions and onto the
output plane in the form of a polygon. The polygon is filled
onto the output plane using scan-line bilinear interpola-
tion. Note that it is possible to distort the mapping so
severely that the input rectangle can be mapped onto a tri-
angle, line, point, twisted hourglass, etc. All of these
cases are resolved except for the hourglass case. Also
note that it may be possible to map into a space that you
cannot get back from (i.e. the above functions have no
inverses).
The point called the center-of-action is the point that is
specified as the origin of the spatial coordinates prior to
applying the transform. The output plane is then shifted so
that its origin lies at that same specified point. The end
result is like specifying what point to put under a magnify-
ing glass.
As a final note, look out for mappings that will take nega-
tive distances and make them positive Since the input plane
is scanned left to right, and top to bottom, it is possible
to overwrite part of the output plane with one or more
regions of the input plane! The result in this case depends
on which part was looked at first by the scanning loop. No
answer is right, so you get one of the many approximations.
Note that image is used for both the input xvimage structure
and the resulting output xvimage structure. This is done to
save space, but you must be careful not to overwrite impor-
tant data.
vexpwarp can take a long time to run...
SEE ALSO
vexpwarp(1), intro(3), vipl(3), verror(3), vutils(3)
lvwarp(1), lvrotate(1), lvresize(1), lvpolyco(1), xvexpr(3)
RESTRICTIONS
vexpwarp will not work on images of type BIT, DOUBLE, COM-
PLEX, or DCOMPLEX data type. vexpwarp does not work on
explicit location data.
AUTHOR
Scott Wilson
COPYRIGHT
Copyright 1991, University of New Mexico. All rights
reserved.
*********************************************************************************
Documentation for avs module vpolyco
INPUT
x X coordinates of source tiepoints
y Y coordinates of source tiepoints
xp X coordinates of target tiepoints
yp Y coordinates of target tiepoints
n number of tiepoints
OUTPUT
xc X bipolynmial coefficients
yc Y bipolynomial coefficients
1 on success, 0 on failure.
DESCRIPTION
vpolyco computes a set of bi-polynomial coefficients that
tries to map the source tiepoints onto the target tiepoints.
The order of the polynomials is controlled by the number of
coordinate pairs in the source tiepoint arrays. The number
of pairs must be the square of an integer. Thus a set of
tiepoint arrays with 9 pairs will produce a coefficient
matrix for a bi-quadratic polynomial.
The input arrays specify the tiepoint coordinates. Each
input array should be of size N and of type FLOAT. The coor-
dinates are stored as pairs of numbers, for example
(x0,y0) (x1,y1) (x2,y2) (x3,y3) is stored in two float
arrays as follows:
x y
-- --
x0 y0
x1 y1
x2 y2
x3 y3
The first input array (x) contains the X coordi-
nates of the tie points in the original (source) image. The
second input array (Y) contains the Y coordinates of the tie
points in the original (source) image.
The output arrays contain the coefficients for the two poly-
nomial mappings, one for the X coordinate and one for the Y
coordinate.
SEE ALSO
vpolyco(1), intro(3), vipl(3), verror(3), vutils(3)
vbilinco(1),vwarp(1)
AUTHOR
Scott Wilson
COPYRIGHT
Copyright 1991, University of New Mexico. All rights
reserved.
*********************************************************************************
Documentation for avs module vwarp
INPUT
image pointer to xvimage structure to be processed
coeffs1 pointer to xvimage structure containing X
polynomial coefficients image
coeffs2 pointer to xvimage structure containing Y
polynomial coefficients image
xca X coordinate of center of action
yca Y coordinate of center of action
OUTPUT
image holds the result of the warp operation. The
output data type is the same as the input
data type.
Return Value: 1 on success, 0 on failure.
DESCRIPTION
vwarp is used to alter the spatial properties of an image
by performing a transformation in which the old coordinates
of a pixel are mapped to a new location by a polynomial
relationship. The old coordinates, (x,y) are related to the
new coordinates (x',y') by the following relations (for
n=2):
x` = A[0,0]*1 + A[1,0]*x + A[2,0]*x^2
+ A[0,1]*y + A[1,1]*x*y + A[2,1]*x^2*y
+ A[0,2]*y^2 + A[1,2]*x*y^2 + A[2,2]*x^2*y^2
y` = B[0,0]*1 + B[1,0]*x + B[2,0]*x^2
+ B[0,1]*y + B[1,1]*x*y + B[2,1]*x^2*y
+ B[0,2]*y^2 + B[1,2]*x*y^2 + B[2,2]*x^2*y^2
Note that the new coordinates can be expressed as a sum of
terms where the coefficients can be arranged in the
following matrix:
1 x x^2 x^3 x^4 --- x^n
1 A[0,0] A[1,0] A[2,0] A[3,0] A[4,0] A[n,0]
y A[0,1] A[1,1] A[2,1] A[3,1] A[4,1] A[n,1]
y^2 A[0,2] A[1,2] A[2,2] A[3,2] A[4,2] A[n,2]
y^3 A[0,3] A[1,3] A[2,3] A[3,3] A[4,3] A[n,3]
y^4 A[0,4] A[1,4] A[2,4] A[3,4] A[4,4] A[n,4]
|
y^n A[0,n] A[1,n] A[2,n] A[3,n] A[4,n] A[n,n]
where the contribution to the polynomial is given by multi-
plying the coefficient by the product of the raised terms
along the top and left side of the matrix.
The coefficients for the the two polynomials (one for x and
one for y) are supplied to vwarp in the form of small
images, the dimensions of which determine the order of the
polynomials. The two coefficient images can be easily
created by hand with the use of vcustom(1). All data types
except COMPLEX and transforms can be used as coefficient
images.
The output image is formed by mapping each individual rec-
tangular region in the input image (composed of four neigh-
boring pixels) through the transform and onto the output
plane in the form of a polygon. The polygon is filled onto
the output plane using scan-line bilinear interpolation.
Note that it is possible to distort mapping so severely that
the input rectangle can be mapped onto a triangle, line,
point, twisted hourglass, etc. All of these cases are
resolved except for the hourglass case. Also note that it
may be possible to transform into a space that you cannot
get back from (i.e. the above matrices have no inverses).
If you intend to get tricky here, you should brush up on
your linear transforms and matrix theory (good book: Golub
and VanLoan, Matrix Computations).
The point called the center-of-action is the point that is
specified as the origin of the spatial coordinates prior to
applying the transform. The output plane is then shifted so
that its origin lies at that same specified point. The end
result is like specifying what point to put under a magnify-
ing glass. When using coefficients supplied by vbilinco(1)
the center of action should be left at zero, which is the
default.
The code looks at the coefficient matrices and constructs
lists of non-zero coefficients and the corresponding power
terms. Only non-zero power terms are computed, so it should
not cost too much to have large matrices as long as they're
sparse.
Look out for transforms that use only even powers of the
coordinates when the center-of-action is at other then
[0,0]. The transform will take negative distances and make
them positive (a well known characteristic of even powers of
a number). Since the input plane is scanned left to right,
and top to bottom, it is possible to overwrite part of the
output plane with one or more regions of the input plane!
The result in this case depends on which part was looked at
first by the scanning loop. No answer is right, so you get
one of the many approximations.
Note that image is used for both the input xvimage structure
and the resulting output xvimage structure. This is done to
save space, but you must be careful not to overwrite impor-
tant data.
SEE ALSO
vwarp(1), intro(3), vipl(3), verror(3), vutils(3) lvro-
tate(1), lvresize(1), lvpolyco(1)
RESTRICTIONS
vwarp will not work on images of type BIT or COMPLEX data