Skip to content

projective_trans_image_sizeprojective_trans_image_sizeProjectiveTransImageSizeProjectiveTransImageSizeprojective_trans_image_sizeT_projective_trans_image_size🔗

Short description🔗

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

Signature🔗

projective_trans_image_size( image Image, out image TransImage, hom_mat2d HomMat2D, string Interpolation, extent.x Width, extent.y Height, string TransformDomain )projective_trans_image_size( Image : TransImage : HomMat2D, Interpolation, Width, Height, TransformDomain : )void ProjectiveTransImageSize( const HObject& Image, HObject* TransImage, const HTuple& HomMat2D, const HTuple& Interpolation, const HTuple& Width, const HTuple& Height, const HTuple& TransformDomain )static void HOperatorSet.ProjectiveTransImageSize( HObject image, out HObject transImage, HTuple homMat2D, HTuple interpolation, HTuple width, HTuple height, HTuple transformDomain )def projective_trans_image_size( image: HObject, hom_mat_2d: Sequence[float], interpolation: str, width: int, height: int, transform_domain: str ) -> HObject

Herror T_projective_trans_image_size( const Hobject Image, Hobject* TransImage, const Htuple HomMat2D, const Htuple Interpolation, const Htuple Width, const Htuple Height, const Htuple TransformDomain )

HImage HImage::ProjectiveTransImageSize( const HHomMat2D& HomMat2D, const HString& Interpolation, Hlong Width, Hlong Height, const HString& TransformDomain ) const

HImage HImage::ProjectiveTransImageSize( const HHomMat2D& HomMat2D, const char* Interpolation, Hlong Width, Hlong Height, const char* TransformDomain ) const

HImage HImage::ProjectiveTransImageSize( const HHomMat2D& HomMat2D, const wchar_t* Interpolation, Hlong Width, Hlong Height, const wchar_t* TransformDomain ) const (Windows only)

HImage HHomMat2D::ProjectiveTransImageSize( const HImage& Image, const HString& Interpolation, Hlong Width, Hlong Height, const HString& TransformDomain ) const

HImage HHomMat2D::ProjectiveTransImageSize( const HImage& Image, const char* Interpolation, Hlong Width, Hlong Height, const char* TransformDomain ) const

HImage HHomMat2D::ProjectiveTransImageSize( const HImage& Image, const wchar_t* Interpolation, Hlong Width, Hlong Height, const wchar_t* TransformDomain ) const (Windows only)

HImage HImage.ProjectiveTransImageSize( HHomMat2D homMat2D, string interpolation, int width, int height, string transformDomain )

HImage HHomMat2D.ProjectiveTransImageSize( HImage image, string interpolation, int width, int height, string transformDomain )

Description🔗

projective_trans_image_sizeProjectiveTransImageSize applies the projective transformation (homography) determined by the homogeneous transformation matrix HomMat2DhomMat2Dhom_mat_2d on the input image Imageimageimage and stores the result into the output image TransImagetransImagetrans_image.

TransImagetransImagetrans_image will be clipped at the output dimensions HeightheightheightxWidthwidthwidth. Apart from this, projective_trans_image_sizeProjectiveTransImageSize is identical to its alternative version projective_trans_imageProjectiveTransImage.

Attention🔗

The used coordinate system is the same as in affine_trans_pixelAffineTransPixel. This means that in fact not HomMat2DhomMat2Dhom_mat_2d is applied but a modified version. Therefore, applying projective_trans_image_sizeProjectiveTransImageSize 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):

\[\begin{eqnarray*} \mvHomVectorTwoD{RowTrans_{i}}{ColTrans_{i}} = \mvHomMatrixTwoDElements{1 & 0 & - 0.5 \\ 0 & 1 & - 0.5} \cdot \textrm{HomMat2D} \cdot \mvHomMatrixTwoDElements{1 & 0 & + 0.5 \\ 0 & 1 & + 0.5} \cdot \mvHomVectorTwoD{Row_{i}}{Col_{i}} \end{eqnarray*}\]

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_grayAreaCenterGray. 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_rotateHomMat2dRotate, 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 HomMat2DhomMat2Dhom_mat_2d before using it in projective_trans_image_sizeProjectiveTransImageSize:

 
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)
hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)
projective_trans_image_size(Image, TransImage, HomMat2DAdapted, 'bilinear', Width, Height, 'false')

For an explanation of the different 2D coordinate systems used in HALCON, see the introduction of chapter Transformations / 2D Transformations.

projective_trans_image_sizeProjectiveTransImageSize 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 TransformDomaintransformDomaintransform_domain is set to 'false'"false". The result can diverge slightly from that calculated on the CPU.

Execution information🔗

Execution information
  • Supports OpenCL compute devices.

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

  • Automatically parallelized on channel level.

  • Automatically parallelized on internal data level.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image(-array) → object (byte* / uint2* / real*)object (byte* / uint2* / real*)HObject (byte* / uint2* / real*)HImage (byte* / uint2* / real*)HObject (byte* / uint2* / real*)Hobject (byte* / uint2* / real*) *allowed for compute devices

Input image.

TransImagetransImagetrans_image (output_object) (multichannel-)image(-array) → object (byte / uint2 / real)object (byte / uint2 / real)HObject (byte / uint2 / real)HImage (byte / uint2 / real)HObject (byte / uint2 / real)Hobject * (byte / uint2 / real)

Output image.

HomMat2DhomMat2Dhom_mat_2d (input_control) hom_mat2d → (real)(real)HTuple (double)HHomMat2D, HTuple (double)Sequence[float]Htuple (double)

Homogeneous projective transformation matrix.

Interpolationinterpolationinterpolation (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Interpolation method for the transformation.

Default: 'bilinear'"bilinear"
List of values: 'bilinear', 'nearest_neighbor'"bilinear", "nearest_neighbor"

Widthwidthwidth (input_control) extent.x → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Output image width.

Heightheightheight (input_control) extent.y → (integer)(integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Output image height.

TransformDomaintransformDomaintransform_domain (input_control) string → (string)(string)HTuple (HString)HTuple (string)strHtuple (char*)

Should the domain of the input image also be transformed?

Default: 'false'"false"
List of values: 'false', 'true'"false", "true"
List of values (for compute devices): 'false'"false"

Combinations with other operators🔗

Combinations

Possible predecessors

vector_to_proj_hom_mat2dVectorToProjHomMat2d, hom_vector_to_proj_hom_mat2dHomVectorToProjHomMat2d, proj_match_points_ransacProjMatchPointsRansac, proj_match_points_ransac_guidedProjMatchPointsRansacGuided, hom_mat3d_projectHomMat3dProject

See also

projective_trans_imageProjectiveTransImage, projective_trans_contour_xldProjectiveTransContourXld, projective_trans_regionProjectiveTransRegion, projective_trans_point_2dProjectiveTransPoint2d, projective_trans_pixelProjectiveTransPixel

Module🔗

Foundation