point_line_to_hom_mat2dT_point_line_to_hom_mat2dPointLineToHomMat2dPointLineToHomMat2dpoint_line_to_hom_mat2d — Approximate an affine transformation from point-to-line correspondences.
This means that
where is a scaling matrix with
identical scaling S in the x and y directions,
is a rotation matrix corresponding
to the rotation angle Phi, and
is the translation vector.
This means that
where is a scaling matrix with
non-identical scaling Sx and Sy in the x and y
directions, is a rotation matrix
corresponding to the rotation angle Phi, and
is the translation vector.
'affine':
A general affine transformation, i.e., a
transformation that can be obtained as follows:
It should be noted that homogeneous transformation matrices refer to
a general right-handed mathematical coordinate system. If a
homogeneous transformation matrix is used to transform images,
regions, XLD contours, or any other data that has been extracted
from images, the row coordinates of the transformation must be
passed in the x coordinates, while the column coordinates must be
passed in the y coordinates. Consequently, the order of passing row
and column coordinates follows the usual order
(RowRowRowRowrowrow,ColumnColumnColumnColumncolumncolumn). This convention is essential to
obtain a right-handed coordinate system for the transformation of
iconic data, and consequently to ensure in particular that rotations
are performed in the correct mathematical direction.
Furthermore, it should be noted that if a homogeneous transformation
matrix is used to transform images, regions, XLD contours, or any
other data that has been extracted from images, it is assumed that
the origin of the coordinate system of the homogeneous
transformation matrix lies in the upper left corner of a pixel. The
image processing operators that return point coordinates, however,
assume a coordinate system in which the origin lies in the center of
a pixel. Therefore, to obtain a consistent homogeneous
transformation matrix, 0.5 must be added to the point coordinates
before computing the transformation.
Execution Information
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
Multithreading scope: global (may be called from any thread).
List of values:
'affine'"affine""affine""affine""affine""affine", 'aniso'"aniso""aniso""aniso""aniso""aniso", 'rigid'"rigid""rigid""rigid""rigid""rigid", 'similarity'"similarity""similarity""similarity""similarity""similarity", 'translation'"translation""translation""translation""translation""translation"
* Use point_line_to_hom_mat2d for alignment.
* Read the reference image.
read_image (Image, ReferenceFileName)
* Set up the metrology model with four lines. Four lines are used
* since this is the minimum number of point-to-line correspondences
* that results in a unique rigid transformation.
Row1 := [RowB1,RowB2,RowB3,RowB4]
Col1 := [ColB1,ColB2,ColB3,ColB4]
Row2 := [RowE1,RowE2,RowE3,RowE4]
Col2 := [ColE1,ColE2,ColE3,ColE4]
create_metrology_model (MetrologyHandle)
add_metrology_object_line_measure (MetrologyHandle, Row1, Col1, \
Row2, Col2, 40, 5, 1, 30, \
[], [], Index)
* Apply the metrology model to the reference image and read out
* the results.
apply_metrology_model (Image, MetrologyHandle)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'row_begin', \
RowBegin)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'column_begin', \
ColBegin)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'row_end', \
RowEnd)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'column_end', \
ColEnd)
* The reference points of the model are the center points of the
* detected line segments. They will be used to compute the
* transformation from the current image to the reference image
* using point_line_to_hom_mat2d below.
RowRef := 0.5*(RowBegin+RowEnd)
ColRef := 0.5*(ColBegin+ColEnd)
for I := 1 to |FileNames|-1 by 1
read_image (Image, FileNames[I])
* Apply the metrology model to the current image and read out
* the line segment coordinates.
apply_metrology_model (Image, MetrologyHandle)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'row_begin', \
RowBegin)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'column_begin', \
ColBegin)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'row_end', \
RowEnd)
get_metrology_object_result (MetrologyHandle, 'all', 'all', \
'result_type', 'column_end', \
ColEnd)
* Determine a rigid transformation based on the point-to-line
* correspondences from the reference points to the extracted
* lines. Note that this determines a transformation from the
* reference points to the lines in the current image.
* Therefore, we must invert this transformation to obtain the
* transformation from the current image to the rerefence image.
point_line_to_hom_mat2d ('rigid', RowRef+0.5, ColRef+0.5, \
RowBegin+0.5, ColBegin+0.5, \
RowEnd+0.5, ColEnd+0.5, HomMat2D)
hom_mat2d_invert (HomMat2D, HomMat2DInvert)
affine_trans_image (Image, ImageTrans, HomMat2DInvert, \
'constant', 'false')
* Now that the current image has been aligned with the
* reference image, we can do some processing based on the
* aligned image ImageTrans.
* [...]
endfor