point_line_to_hom_mat2dT_point_line_to_hom_mat2dPointLineToHomMat2dPointLineToHomMat2d (Operator)

Name

point_line_to_hom_mat2dT_point_line_to_hom_mat2dPointLineToHomMat2dPointLineToHomMat2d — Erzeugt eine Näherung für eine affine Transformation aus Punkt-zu-Gerade-Korrespondenzen.

Signatur

point_line_to_hom_mat2d( : : TransformationType, Px, Py, L1x, L1y, L2x, L2y : HomMat2D)

Herror T_point_line_to_hom_mat2d(const Htuple TransformationType, const Htuple Px, const Htuple Py, const Htuple L1x, const Htuple L1y, const Htuple L2x, const Htuple L2y, Htuple* HomMat2D)

void PointLineToHomMat2d(const HTuple& TransformationType, const HTuple& Px, const HTuple& Py, const HTuple& L1x, const HTuple& L1y, const HTuple& L2x, const HTuple& L2y, HTuple* HomMat2D)

void HHomMat2D::PointLineToHomMat2d(const HString& TransformationType, const HTuple& Px, const HTuple& Py, const HTuple& L1x, const HTuple& L1y, const HTuple& L2x, const HTuple& L2y)

void HHomMat2D::PointLineToHomMat2d(const char* TransformationType, const HTuple& Px, const HTuple& Py, const HTuple& L1x, const HTuple& L1y, const HTuple& L2x, const HTuple& L2y)

void HHomMat2D::PointLineToHomMat2d(const wchar_t* TransformationType, const HTuple& Px, const HTuple& Py, const HTuple& L1x, const HTuple& L1y, const HTuple& L2x, const HTuple& L2y)   (Nur Windows)

static void HOperatorSet.PointLineToHomMat2d(HTuple transformationType, HTuple px, HTuple py, HTuple l1x, HTuple l1y, HTuple l2x, HTuple l2y, out HTuple homMat2D)

void HHomMat2D.PointLineToHomMat2d(string transformationType, HTuple px, HTuple py, HTuple l1x, HTuple l1y, HTuple l2x, HTuple l2y)

Beschreibung

point_line_to_hom_mat2dpoint_line_to_hom_mat2dPointLineToHomMat2dPointLineToHomMat2dPointLineToHomMat2d berechnet eine Näherung für eine affine Transformation aus Punkt-zu-Gerade-Korrespondenzen und liefert sie in der homogenen Transformationsmatrix HomMat2DHomMat2DHomMat2DHomMat2DhomMat2D zurück (siehe hom_mat2d_to_affine_parhom_mat2d_to_affine_parHomMat2dToAffineParHomMat2dToAffineParHomMat2dToAffinePar für den Aufbau der homogenen Transformationsmatrix).

Die Punkte werden in den Tupeln (PxPxPxPxpx,PyPyPyPypy) übergeben. Ihre korrespondierenden Geraden werden durch zwei Punkte auf der Geraden spezifiziert, die in (L1xL1xL1xL1xl1x,L1yL1yL1yL1yl1y) und (L2xL2xL2xL2xl2x,L2yL2yL2yL2yl2y) übergeben werden. Korrespondierende Punkte und Geraden müssen an denselben Indexpositionen in diesen Tupeln stehen.

Der Typ der zu bestimmenden Transformation wird mit TransformationTypeTransformationTypeTransformationTypeTransformationTypetransformationType festgelegt. Jeder Transformationstyp erfordert eine bestimmte Mindestanzahl von Punkt-zu-Gerade-Korrespondenzen, wie in der folgenden Tabelle beschrieben:

TransformationTypeTransformationTypeTransformationTypeTransformationTypetransformationType Typ der Transformation Mindestanzahl von Korrespondenzen
'translation' Translation 2
'rigid' Starre affine Transformation 3
'similarity' Ähnlichkeitstransformation 4
'aniso' Anisotrope Ähnlichkeitstransformation 5
'affine' Allgemeine affine Transformation 6

Die unterstützten Transformationstypen können wie folgt beschrieben werden:

'translation':

Eine Translation, d.h., eine Transformation, die wie folgt erzeugt werden kann: hom_mat2d_identity (HomMat2D) hom_mat2d_translate (HomMat2D, Tx, Ty, HomMat2D) Dies bedeutet, dass wobei der Translationvektor ist.

'rigid':

Eine starre affine Transformation, d.h., eine Transformation, die wie folgt erzeugt werden kann: hom_mat2d_identity (HomMat2D) hom_mat2d_rotate (HomMat2D, Phi, 0, 0, HomMat2D) hom_mat2d_translate (HomMat2D, Tx, Ty, HomMat2D) Dies bedeutet, dass wobei eine zum Rotationswinkel Phi gehörige Rotationsmatrix und der Translationvektor ist.

'similarity':

Eine Ähnlichkeitstransformation, d.h., eine Transformation, die wie folgt erzeugt werden kann (beachten Sie die identischen Skalierungsfaktoren bei hom_mat2d_scalehom_mat2d_scaleHomMat2dScaleHomMat2dScaleHomMat2dScale): hom_mat2d_identity (HomMat2D) hom_mat2d_scale (HomMat2D, S, S, 0, 0, HomMat2D) hom_mat2d_rotate (HomMat2D, Phi, 0, 0, HomMat2D) hom_mat2d_translate (HomMat2D, Tx, Ty, HomMat2D) Dies bedeutet, dass wobei eine Skalierungsmatrix mit identischer Skalierung S in x- und y-Richtung, eine zum Rotationswinkel Phi gehörige Rotationsmatrix und der Translationvektor ist.

'aniso':

Eine anisotrope Ähnlichkeitstransformation, d.h., eine Transformation, die wie folgt erzeugt werden kann (beachten Sie die unterschiedlichen Skalierungsfaktoren bei hom_mat2d_scalehom_mat2d_scaleHomMat2dScaleHomMat2dScaleHomMat2dScale): hom_mat2d_identity (HomMat2D) hom_mat2d_scale (HomMat2D, Sx, Sy, 0, 0, HomMat2D) hom_mat2d_rotate (HomMat2D, Phi, 0, 0, HomMat2D) hom_mat2d_translate (HomMat2D, Tx, Ty, HomMat2D) Dies bedeutet, dass wobei eine Skalierungsmatrix mit nicht-identischer Skalierung Sx und Sy in x- und y-Richtung, eine zum Rotationswinkel Phi gehörige Rotationsmatrix und der Translationvektor ist.

'affine':

Eine allgemeine affine Transformation, d.h., eine Transformation, die wie folgt erzeugt werden kann: hom_mat2d_identity (HomMat2D) hom_mat2d_scale (HomMat2D, Sx, Sy, 0, 0, HomMat2D) hom_mat2d_slant (HomMat2D, Theta, 'y', 0, 0, HomMat2D) hom_mat2d_rotate (HomMat2D, Phi, 0, 0, HomMat2D) hom_mat2d_translate (HomMat2D, Tx, Ty, HomMat2D) Dies bedeutet, dass wobei beliebige Zahlen sind.

Die Transformation wird berechnet, indem die Summe der quadrierten Abstände der mit der berechneten Transformation transformierten Punkte (PxPxPxPxpx,PyPyPyPypy) zu den Geraden, die durch (L1xL1xL1xL1xl1x,L1yL1yL1yL1yl1y) und (L2xL2xL2xL2xl2x,L2yL2yL2yL2yl2y) gegeben sind, minimiert werden. Die Geraden werden dabei als unendlich lange Geraden betrachtet. Das bedeutet, dass die mit der Transformation HomMat2DHomMat2DHomMat2DHomMat2DhomMat2D transformierten Punkte (PxPxPxPxpx,PyPyPyPypy) nicht „zwischen“ (L1xL1xL1xL1xl1x,L1yL1yL1yL1yl1y) und (L2xL2xL2xL2xl2x,L2yL2yL2yL2yl2y) liegen müssen. Eine Ausnahme dieser Regel tritt auf, falls starre affine Transformationen oder anisotrope Ähnlichkeitstransformation aus der minimalen Anzahl von 3 bzw. 5 Punkt-zu-Gerade-Korrespondenzen bestimmt werden. In diesem Fall existieren im allgemeinen zwei mögliche Lösungen, die beide einen Fehler von 0 aufweisen. Der Algorithmus liefert die Lösung zurück, für die die transformierten Punkte so nahe wie möglich an dem Geradenstück (der Strecke) liegen, die durch (L1xL1xL1xL1xl1x,L1yL1yL1yL1yl1y) und (L2xL2xL2xL2xl2x,L2yL2yL2yL2yl2y) gegeben ist. Falls eine eindeutige Lösung gewünscht ist, sollte eine zusätzliche Punkt-zu-Gerade-Korrespondenz verwendet werden (d.h. 4 bzw. 6).

HomMat2DHomMat2DHomMat2DHomMat2DhomMat2D kann direkt mit den Operatoren, die Daten mit affinen Abbildungen transformieren, z.B. affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImage, verwendet werden.

Achtung

Es ist zu beachten, dass homogene Transformationsmatrizen sich auf ein allgemeines rechtshändiges mathematisches Koordinatensystem beziehen. Falls eine homogene Transformationsmatrix zur Transformation von Bildern, Regionen, XLD-Konturen oder anderen Daten, die aus Bildern extrahiert wurden, verwendet werden soll, ist zu beachten, dass die Zeilenkoordinaten in den x-Koordinaten und die Spaltenkoordinaten in den y-Koordinaten übergeben werden müssen. Die Übergabereihenfolge von Zeilen- und Spaltenkoordinaten entspricht also der üblichen Reihenfolge (RowRowRowRowrow,ColumnColumnColumnColumncolumn). Diese Konvention ist unerlässlich, um bei der Transformation von Bilddaten ein rechtshändiges Koordinatensystem zu erhalten, so dass z.B. insbesondere Rotationen in der mathematisch korrekten Drehrichtung ausgeführt werden.

Weiterhin ist zu beachten, dass, falls eine homogene Transformationsmatrix zur Transformation von Bildern, Regionen, XLD-Konturen oder anderen Daten, die aus Bildern extrahiert wurden, verwendet werden soll, angenommen wird, dass der Ursprung des Koordinatensystems der homogenen Transformationsmatrix in der linken oberen Ecke des Pixels liegt. Die Bildverarbeitungsoperatoren, die Punktkoordinaten zurückliefern, nehmen hingegen ein Koordinatensystem an, in dem der Ursprung in der Mitte eines Pixels liegt. Daher muss, um eine konsistente homogene Transformationsmatrix zu erhalten, 0.5 zu den Punktkoordinaten addiert werden, bevor die Transformation berechnet wird.

Ausführungsinformationen

Parameter

TransformationTypeTransformationTypeTransformationTypeTransformationTypetransformationType (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Typ der zu berechnenden Transformation.

Defaultwert: 'rigid' "rigid" "rigid" "rigid" "rigid"

Werteliste: 'affine'"affine""affine""affine""affine", 'aniso'"aniso""aniso""aniso""aniso", 'rigid'"rigid""rigid""rigid""rigid", 'similarity'"similarity""similarity""similarity""similarity", 'translation'"translation""translation""translation""translation"

PxPxPxPxpx (input_control)  point.x-array HTupleHTupleHtuple (real) (double) (double) (double)

X-Koordinaten der originalen Punkte.

PyPyPyPypy (input_control)  point.y-array HTupleHTupleHtuple (real) (double) (double) (double)

Y-Koordinaten der originalen Punkte.

L1xL1xL1xL1xl1x (input_control)  point.x-array HTupleHTupleHtuple (real) (double) (double) (double)

X-Koordinaten des ersten Punkts auf der korrespondierenden Gerade.

L1yL1yL1yL1yl1y (input_control)  point.y-array HTupleHTupleHtuple (real) (double) (double) (double)

Y-Koordinaten des ersten Punkts auf der korrespondierenden Gerade.

L2xL2xL2xL2xl2x (input_control)  point.x-array HTupleHTupleHtuple (real) (double) (double) (double)

X-Koordinaten des zweiten Punkts auf der korrespondierenden Gerade.

L2yL2yL2yL2yl2y (input_control)  point.y-array HTupleHTupleHtuple (real) (double) (double) (double)

Y-Koordinaten des zweiten Punkts auf der korrespondierenden Gerade.

HomMat2DHomMat2DHomMat2DHomMat2DhomMat2D (output_control)  hom_mat2d HHomMat2D, HTupleHTupleHtuple (real) (double) (double) (double)

Ausgabe-Transformationsmatrix.

Beispiel (HDevelop)

* 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

Nachfolger

affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImage, affine_trans_image_sizeaffine_trans_image_sizeAffineTransImageSizeAffineTransImageSizeAffineTransImageSize, affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegion, affine_trans_contour_xldaffine_trans_contour_xldAffineTransContourXldAffineTransContourXldAffineTransContourXld, affine_trans_polygon_xldaffine_trans_polygon_xldAffineTransPolygonXldAffineTransPolygonXldAffineTransPolygonXld, affine_trans_point_2daffine_trans_point_2dAffineTransPoint2dAffineTransPoint2dAffineTransPoint2d

Siehe auch

vector_to_hom_mat2dvector_to_hom_mat2dVectorToHomMat2dVectorToHomMat2dVectorToHomMat2d, vector_to_anisovector_to_anisoVectorToAnisoVectorToAnisoVectorToAniso, vector_to_similarityvector_to_similarityVectorToSimilarityVectorToSimilarityVectorToSimilarity, vector_to_rigidvector_to_rigidVectorToRigidVectorToRigidVectorToRigid

Modul

Foundation