Operators

projective_trans_image_size (Operator)

Name

projective_trans_image_size — Apply a projective transformation to an image and specify the output image size.

Signature

projective_trans_image_size(Image : TransImage : HomMat2D, Interpolation, Width, Height, TransformDomain : )

Description

projective_trans_image_size applies the projective transformation (homography) determined by the homogeneous transformation matrix HomMat2D on the input image Image and stores the result into the output image TransImage.

TransImage will be clipped at the output dimensions HeightxWidth. Apart from this, projective_trans_image_size is identical to its alternative version projective_trans_image.

Attention

The used coordinate system is the same as in affine_trans_pixel. This means that in fact not HomMat2D is applied but a modified version. Therefore, applying projective_trans_image_size corresponds to the following chain of transformations, which is applied to each point (Row_i, Col_i) of the image (input and output pixels as homogeneous vectors):

/ RowTrans_i \   / 1 0 -0.5 \              / 1 0 +0.5 \   / Row_i \
| ColTrans_i | = | 0 1 -0.5 | * HomMat2D * | 0 1 +0.5 | * | Col_i |
\    1       /   \ 0 0   1  /              \ 0 0   1  /   \  1    /

As an effect, you might get unexpected results when creating projective transformations based on coordinates that are derived from the image, e.g., by operators like area_center_gray. For example, if you use this operator to calculate the center of gravity of a rotationally symmetric image and then rotate the image around this point using hom_mat2d_rotate, the resulting image will not lie on the original one. In such a case, you can compensate this effect by applying the following translations to HomMat2D before using it in projective_trans_image_size:

hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)
'bilinear', Width, Height, 'false')

projective_trans_image_size can be executed on OpenCL devices if the input image does not exceed the maximum size of image objects of the selected device and the parameter TransformDomain is set to 'false'. The result can diverge slightly from that calculated on the CPU.

Parallelization

• Supports OpenCL compute devices.
• Multithreading type: reentrant (runs in parallel with non-exclusive operators).
• Automatically parallelized on tuple level.
• Automatically parallelized on channel level.
• Automatically parallelized on internal data level.

Parameters

Image (input_object)  (multichannel-)image(-array) object (byte* / uint2* / real*) *allowed for compute devices

Input image.

TransImage (output_object)  (multichannel-)image(-array) object (byte / uint2 / real)

Output image.

HomMat2D (input_control)  hom_mat2d (real)

Homogeneous projective transformation matrix.

Interpolation (input_control)  string (string)

Interpolation method for the transformation.

Default value: 'bilinear'

List of values: 'bilinear', 'nearest_neighbor'

Width (input_control)  extent.x (integer)

Output image width.

Height (input_control)  extent.y (integer)

Output image height.

TransformDomain (input_control)  string (string)

Should the domain of the input image also be transformed?

Default value: 'false'

List of values: 'false', 'true'

List of values (for compute devices): 'false'