projective_trans_contour_xld — Apply a projective transformation to an XLD contour.
projective_trans_contour_xld applies the projective transformation specified by the homogeneous matrix HomMat2D on the contours in Contours and returns the transformed contours in ContoursProjTrans.
For creation and interpretation details of this matrix see also projective_trans_image.
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_contour_xld corresponds to the following chain of transformations, which is applied to each point (Row_i, Col_i) of the contour (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 contour, e.g., by operators like area_center_xld. For example, if you use this operator to calculate the center of gravity of a rotationally symmetric XLD contour and then rotate the contour around this point using hom_mat2d_rotate, the resulting contour 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_contour_xld:
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp) hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted) projective_trans_contour_xld(Contours, ContoursAffinTrans, HomMat2DAdapted)
Homogeneous projective transformation matrix.
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, projective_trans_image_size, projective_trans_region, projective_trans_point_2d, projective_trans_pixel