affine_trans_image_size ( Image : ImageAffinTrans : HomMat2D, Interpolation, Width, Height : )

Apply an arbitrary affine 2D transformation to an image and specify the output image size.

affine_trans_image_size applies an arbitrary affine 2D transformation, i.e., scaling, rotation, translation, and slant (skewing), to the images given in Image and returns the transformed images in ImageAffinTrans. The affine transformation is described by the homogeneous transformation matrix given in HomMat2D, which can be created using the operators hom_mat2d_identity, hom_mat2d_scale, hom_mat2d_rotate, hom_mat2d_translate, etc., or be the result of operators like vector_angle_to_rigid.

The components of the homogeneous transformation matrix are interpreted as follows: The row coordinate of the image corresponds to the x coordinate of the matrix, while the column coordinate of the image corresponds to the y coordinate of the matrix. This is necessary to obtain a right-handed coordinate system for the image. In particular, this assures that rotations are performed in the correct direction. Note that the (x,y) order of the matrices quite naturally corresponds to the usual (row,column) order for coordinates in the image.

The region of the input image is ignored, i.e., assumed to be the full rectangle of the image. The region of the resulting image is set to the transformed rectangle of the input image. If necessary, the resulting image is filled with zero (black) outside of the region of the original image.

Generally, transformed points will lie between pixel coordinates. Therefore, an appropriate interpolation scheme has to be used. The interpolation can also be used to avoid aliasing effects for scaled images. The quality and speed of the interpolation can be set by the parameter Interpolation:

  none
       No interpolation: The gray value is determined from the
       nearest pixel's gray value (possibly low quality, very fast).

  constant
       Use equally weighted interpolation between adjacent pixels
       (medium quality and run time).

  weighted
       Use Gaussian interpolation between adjacent pixels (best
       quality, slow).

In addition, the system parameter 'int_zooming' (see set_system) affects the accuracy of the transformation. If 'int_zooming' is set to 'true', the transformation for byte, int2 and uint2 images is carried out internally using fixed point arithmetic, leading to much shorter execution times. However, the accuracy of the transformed gray values is smaller in this case. For byte images, the differences to the more accurate calculation (using 'int_zooming' = 'false') is typically less than two gray levels. Correspondingly, for int2 and uint2 images, the gray value differences are less than 1/128 times the dynamic gray value range of the image, i.e., they can be as large as 512 gray levels if the entire dynamic range of 16 bit is used. For real images, the parameter 'int_zooming' does not affect the accuracy, since the internal calculations are always done using floating point arithmetic.

The size of the target image is specifed by the parameters Width and Height. Note that the image is always clipped at the left and upper edge, i.e., all image parts that have negative coordinates after the transformation are clipped. If the affine transformation (in particular, the translation) is chosen appropriately, a part of the image can be transformed as well as cropped in one call. This is useful, for example, when using the variation model (see compare_variation_model), because with this mechanism only the parts of the image that should be examined, are transformed.


Attention

The region of the input image is ignored.


Parameters

Image (input_object)
(multichannel-)image(-array) -> object : byte / int2 / uint2 / real
Input image.

ImageAffinTrans (output_object)
(multichannel-)image(-array) -> object : byte / int2 / uint2 / real
Transformed image.

HomMat2D (input_control)
affine2d-array -> real
Input transformation matrix.
Number of elements: 6

Interpolation (input_control)
string -> string
Type of interpolation.
Default value: 'constant'
List of values: 'none', 'constant', 'weighted'

Width (input_control)
extent.x -> integer
Width of the output image.
Default value: 640
Suggested values: 128, 160, 192, 256, 320, 384, 512, 640, 768

Height (input_control)
extent.y -> integer
Height of the output image.
Default value: 480
Suggested values: 120, 128, 144, 240, 256, 288, 480, 512, 576


Result

affine_trans_image_size returns 2 (H_MSG_TRUE) if all parameter values are correct. If the input is empty the behaviour can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception handling is raised.


Parallelization Information

affine_trans_image_size is reentrant and automatically parallelized (on tuple level, channel level).


Possible Predecessors

hom_mat2d_identity, hom_mat2d_translate, hom_mat2d_rotate, hom_mat2d_scale


Alternatives

affine_trans_image, zoom_image_size, zoom_image_factor, mirror_image, rotate_image, affine_trans_region


See also

set_part_style


Module

Image filters



Copyright © 1996-2005 MVTec Software GmbH