NAME
warp_op -- warp an image
PROTOTYPE
unitptr warp_op( int iOperands, int iDx, int iDy, char *pcOpt, unitptr uHost)
ARGUMENTS
- int iOperands
- nr of operand units. If 0, the unit computes a linear or linear logarithmic transform (depending on the option string pcOpt, see below; otherwise, the transform is determined by the operand units.
- int iDx
- width of image region
- int iDy
- height of image region
- char *pcOpt
- options: if 0 operands are specified, the presence of a token %L requests a logarithmic affine transform (see below); otherwise, a linear affine transform is computed
- unitptr uHost
- host unit
RETURN VALUE:
A pointer to the created unit or NULL in the case of an error.
INTERFACE OF CREATED UNIT:
- X_in[iDx*iDy]:
- (packed input field 0) input image
- Y_in[2]:
- (input field 1) source location of pixel, provided
by operand unit(s)
- Z_in[1]:
- (input field 3) pixel value to be used when
source location misses input image rectangle.
- in_3[6]:
- (input field 2) parameters (tx,ty,a,b,zx,zy) of an
affine or logarithmic warping transformation
of the input image into the output image. The point
(tx,ty) will be mapped into the center, a and
b are rotation and shear angles about the new center,
zx and zy are zoom
factors along the directions of the input image.
For a more detailed description, see below.
- CTL_in[1]:
- (control field)
- X_out[iDx*iDy]:
- (packed output field 0) warped output image
- Y_out[2]:
- (output field 1) destination location of pixel
from which source location must be computed by
by operand unit(s)
EXECUTION OF CREATED UNIT:
Applies an affine, logarithmic affine or general transform to
the pixel locations of the input image. The transform is chosen
by the value of iOperands in conjunction with pcOpt. If
iOperands=0, the logarithmic or the affine transformation is chosen
(depending on the presence or absence of the token %L in pcOpt)
and the unit
will create an internal table (which is dynamically
pdated whenever the input parameters for the
appings change) from which the transform can be computed very rapidly.
therwise, the unit executes its operand(s) to obtain the specified
ransform (see below).
TRANSFORMATIONS:
Affine Transformation:
The pixel location r'=(x',y') in the output image is determined from
the pixel location r=(x,y) in the input image by the following affine
transformation:
x' = dx/2 + cos(a+b)*(x-tx)/zx - sin(a-b)*(y-ty)/zy
y' = dy/2 + sin(a+b)*(x-tx)/zx + cos(a-b)*(y-ty)/zy
The input fields inp_2[6]=(tx,ty,a,b,zx,zy) specifies the involved
six parameters tx,ty,a,b,zx,zy (with defaults zx=zy=1 and zero for
the others).
The above transformation maps the point (tx,ty) into the center point
(dx/2,dy/2) of the output image.
The entire transformation can be geometrically described as a composition
of the following three simpler transforms:
- 1.
- A translation of the input image that brings the point (tx,ty) to
the center point (dx/2,dy/2).
- 2.
- A horizontal and vertical zoom with stretch factors of zx and zy.
- 3.
- A `shear transformation'' with the center point P=(dx/2,dy/2) as
its fixed point, rotating the horizontal axis passing
through P by a counterclockwise angle of b, and the vertical
axis passing through P by the opposite angle of -b
- 4.
- A final counterclockwise rotation about the angle a about the center P
Logarithmic affine transformation:
This differs from the affine transformation by replacing the zooming step 2
and the shear transformation by a single, non-linear transformation that
is an isotropic radial zoom operation, remapping a
point at a distance r from the center P=(dx/2,dy/2) into the new
distance
r' = zy*log(1+r/zx)
Thus, the entire transformation is now:
- 1.
- A translation of the input image that brings the point (tx,ty) to
the center point (dx/2,dy/2).
- 2.
- The above non-linear zoom about the center P
- 3.
- A final counterclockwise rotation about angle a
That is, zx sets the scale in the input image, at which the nonlinearity
begins to be appreciable, while zy specifies an isotropic linear zoom
for the result image. For points that are much closer than zx to
the center point (tx,ty) of the input image, the transformation
is approximately linear affine and corresponds to parameters of
(tx,ty,a,0,zx/zy,zx/zy) in the parametrization of the previous
section.
General Transformation:
In this case, the transformation must be specified by one or several
operand units. This works as follows: the operand(s) is called once
for each output pixel location (i',j'), with the values of i' and
j' available at output field out_1[2]. From these values, the
operand unit(s) is expected to compute a pixel location (i,j) that
specifies the location in the input image from which the intensity
value is to be taken. (i,j) must be fed to input field in_1[2].
IMPLEMENTATION NOTE:
The output image is computed by using the inverse transforms
of the above to identify for each destination pixel the correct
source point. Then, the closest pixel to the source location determines
the value in the result image. The unit does not recompute the transformation
at each pass. Instead, it uses an internal mapping table that is
updated only whenever some input parameters change.
FILE
/amnt/loge/users/nistaff02/nistaff/rhaschke/nst7/man/../o.linux//../foldersrc/nst_pixel.c