Creates a 3x3 affine transformation matrix that represents the alignment information contained within the
RegistrationResult.
public Matrix GetAffineTransformation()
public:
Matrix^ GetAffineTransformation();
'Declaration
Public Function GetAffineTransformation() As Matrix
'Usage
Dim instance As RegistrationResult
Dim value As Matrix
value = instance.GetAffineTransformation()
Return Value
An affine transformation matrix that represents the alignment transformation information stored within the RegistrationResult. This transformation matrix represents the mapping from the coordinate system of the unaligned image, to the coordinate system of the model (template) image.If the
State of the RegistrationResult is equal to RegistrationState.Failure, the value of the returned matrix is not guaranteed.
This sample shows how to call GetAffineTransformation and then
use the returned Matrix to compute the location of a field in
the unaligned form image, based on coordinates of the field in
the template image.
// generate the affine transformation
System.Drawing.Drawing2D.Matrix affineTransform =
myRegistrationResult.GetAffineTransformation();
// invert the transformation so that it represents the
// mapping from the template image to the filled image
affineTransform.Invert();
// define a field within the template image
System.Drawing.Rectangle myField = new System.Drawing.Rectangle(10, 10, 200, 50);
// Get points that represent the corners of the field
System.Drawing.Point topLeft, topRight, bottomLeft, bottomRight;
topLeft = new System.Drawing.Point(myField.Left, myField.Top);
topRight = new System.Drawing.Point(myField.Right, myField.Top);
bottomLeft = new System.Drawing.Point(myField.Left, myField.Bottom);
bottomRight = new System.Drawing.Point(myField.Right, myField.Bottom);
// create array of the points
System.Drawing.Point[] cornersOfField =
new System.Drawing.Point[] { topLeft, topRight, bottomLeft, bottomRight };
// map the points into the filled image
affineTransform.TransformPoints(cornersOfField);
// use the transformed points
int newXTopLeft = cornersOfField[0].X;
int newYTopLeft = cornersOfField[0].Y;