Operators |
projective_trans_image — Apply a projective transformation to an image.
projective_trans_image(Image : TransImage : HomMat2D, Interpolation, AdaptImageSize, TransformDomain : )
projective_trans_image 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.
If the parameter AdaptImageSize ist set to 'false' , TransImage will have the same size as Image; if AdaptImageSize is 'true' , the output image size will be automatically adapted so that all non-negative points of the transformed image are visible.
The parameter Interpolation determines, which interpolation method is used to determine the gray values of the output image. For Interpolation = 'nearest_neighbor' , the gray value is determined from the nearest pixel in the input image. This mode is very fast, but also leads to the typical “jagged” appearance for large enlargements of the image. For Interpolation = 'bilinear' , the gray values are interpolated bilinearly, leading to longer runtimes, but also to significantly improved results.
The parameter TransformDomain can be used to determine whether the domain of Image is also transformed. Since the transformation of the domain costs runtime, this parameter should be used to specify whether this is desired or not. If TransformDomain is set to 'false' the domain of the input image is ignored and the complete image is transformed.
The projective transformation matrix could for example be created using the operator vector_to_proj_hom_mat2d.
In a homography the points to be projected are represented by homogeneous vectors of the form (x,y,w). A Euclidean point can be derived as (x',y') = .
Just like in affine_trans_image, x represents the row coordinate while y represents the column coordinate in projective_trans_image . With this convention, affine transformations are a special case of projective transformations in which the last row of HomMat2D is of the form (0,0,c).
For images of type 'byte' or 'uint2' the system parameter 'int_zooming' selects between fast calculation in fixed point arithmetics ('int_zooming' = 'true' ) and highly accurate calculation in floating point arithmetics ('int_zooming' = 'false' ). Especially for Interpolation = 'bilinear' , however, fixed point calculation can lead to minor gray value deviations since the faster algorithm achieves an accuracy of no more than pixels. Therefore, when applying large scales 'int_zooming' = 'false' is recommended.
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 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):
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 :
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp) hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted) projective_trans_image(Image, TransImage, HomMat2DAdapted, 'bilinear', 'false', 'false')
For an explanation of the different 2D coordinate systems used in HALCON, see the introduction of chapter Transformations / 2D Transformations.
projective_trans_image 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.
Input image.
Output image.
Homogeneous projective transformation matrix.
Interpolation method for the transformation.
Default value: 'bilinear'
List of values: 'bilinear' , 'nearest_neighbor'
Adapt the size of the output image automatically?
Default value: 'false'
List of values: 'false' , 'true'
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'
vector_to_proj_hom_mat2d, hom_vector_to_proj_hom_mat2d, proj_match_points_ransac, proj_match_points_ransac_guided, hom_mat3d_project
projective_trans_image_size, projective_trans_contour_xld, projective_trans_region, projective_trans_point_2d, projective_trans_pixel
Foundation
Operators |