- image
- RasterImage object that references the transformed image.
- referencePoints
- Pointer to an array of reference points. These points represent the center of mass points for the registration marks in the reference image. You have to provide this information.
- transformedPoints
- Pointer to an array of transformed points. These points are the center of mass points in the image. You have to provide this information.
Visual Basic (Declaration) | |
---|---|
Public Shared Function GetTransformationParameters( _ ByVal image As RasterImage, _ ByVal referencePoints() As LeadPoint, _ ByVal transformedPoints() As LeadPoint _ ) As TransformationParameters |
Visual Basic (Usage) | Copy Code |
---|---|
Dim image As RasterImage Dim referencePoints() As LeadPoint Dim transformedPoints() As LeadPoint Dim value As TransformationParameters value = CoreUtilities.GetTransformationParameters(image, referencePoints, transformedPoints) |
C# | |
---|---|
public static TransformationParameters GetTransformationParameters( RasterImage image, LeadPoint[] referencePoints, LeadPoint[] transformedPoints ) |
C++/CLI | |
---|---|
public: static TransformationParameters GetTransformationParameters( RasterImage^ image, array<LeadPoint>^ referencePoints, array<LeadPoint>^ transformedPoints ) |
Parameters
- image
- RasterImage object that references the transformed image.
- referencePoints
- Pointer to an array of reference points. These points represent the center of mass points for the registration marks in the reference image. You have to provide this information.
- transformedPoints
- Pointer to an array of transformed points. These points are the center of mass points in the image. You have to provide this information.
Return Value
TransformationParametersThis example computes the translation parameters. The example makes the assumption that you have saved the position of the registration marks of the reference image in a file. You should modify this example and replace the manual assignment of the rmData with your own code to load the reference registration mark data before testing this example.
Visual Basic | Copy Code |
---|---|
Public Sub GetTransformationParametersExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command Dim rmData(2) As SearchRegistrationMarksCommandData ' Mark1 rmData(0) = New SearchRegistrationMarksCommandData rmData(0).Rectangle = New LeadRect(680, 20, 941 - 680, 218 - 20) Dim pt0(0) As LeadPoint rmData(0).MarkDetectedPoints = pt0 rmData(0).Width = 31 rmData(0).Height = 29 rmData(0).Type = RegistrationMarkCommandType.TShape rmData(0).MinimumScale = 90 rmData(0).MaximumScale = 110 rmData(0).SearchMarkCount = 1 ' Mark2 rmData(1) = New SearchRegistrationMarksCommandData rmData(1).Rectangle = New LeadRect(665, 790, 899 - 665, 961 - 790) Dim pt1(0) As LeadPoint rmData(1).MarkDetectedPoints = pt1 rmData(1).Width = 31 rmData(1).Height = 29 rmData(1).Type = RegistrationMarkCommandType.TShape rmData(1).MinimumScale = 90 rmData(1).MaximumScale = 110 rmData(1).SearchMarkCount = 1 ' Mark3 rmData(2) = New SearchRegistrationMarksCommandData rmData(2).Rectangle = New LeadRect(7, 1073, 298 - 7, 1246 - 1073) Dim pt2(0) As LeadPoint rmData(2).MarkDetectedPoints = pt2 rmData(2).Width = 31 rmData(2).Height = 29 rmData(2).Type = RegistrationMarkCommandType.TShape rmData(2).MinimumScale = 90 rmData(2).MaximumScale = 110 rmData(2).SearchMarkCount = 1 Dim command1 As New SearchRegistrationMarksCommand(rmData) command1.Run(leadImage) If ((rmData(2).MarkDetectedCount <> 1) OrElse (rmData(1).MarkDetectedCount <> 1) OrElse (rmData(0).MarkDetectedCount <> 1)) Then Return End If Dim original() As LeadPoint = _ { _ New LeadPoint(81400, 11300), _ New LeadPoint(78600, 87400), _ New LeadPoint(14300, 115400) _ } Dim detected() As LeadPoint = _ { _ rmData(0).MarkDetectedPoints(0), _ rmData(1).MarkDetectedPoints(0), _ rmData(2).MarkDetectedPoints(0) _ } ' Find center of mass for detected registration marks in the transformed image Dim transformed() As LeadPoint = CoreUtilities.GetRegistrationMarksCenterMass(leadImage, detected) ' Find transformation parameters Dim parameters As TransformationParameters = CoreUtilities.GetTransformationParameters(leadImage, original, transformed) ' Apply transformatin parameters to correct the image Dim applyCommand As New ApplyTransformationParametersCommand(parameters.XTranslation, parameters.YTranslation, parameters.Angle, parameters.XScale, parameters.YScale, ApplyTransformationParametersCommandFlags.Normal) applyCommand.Run(leadImage) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class |
C# | Copy Code |
---|---|
public void GetTransformationParametersExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command SearchRegistrationMarksCommandData[] rmData = new SearchRegistrationMarksCommandData[3]; //Mark1 rmData[0] = new SearchRegistrationMarksCommandData(); rmData[0].Rectangle = new LeadRect(680, 20, 941 - 680, 218 - 20); rmData[0].MarkDetectedPoints = new LeadPoint[1]; rmData[0].Width = 31; rmData[0].Height = 29; rmData[0].Type = RegistrationMarkCommandType.TShape; rmData[0].MinimumScale = 90; rmData[0].MaximumScale = 110; rmData[0].SearchMarkCount = 1; //Mark2 rmData[1] = new SearchRegistrationMarksCommandData(); rmData[1].Rectangle = new LeadRect(665, 790, 899 - 665, 961 - 790); rmData[1].MarkDetectedPoints = new LeadPoint[1]; rmData[1].Width = 31; rmData[1].Height = 29; rmData[1].Type = RegistrationMarkCommandType.TShape; rmData[1].MinimumScale = 90; rmData[1].MaximumScale = 110; rmData[1].SearchMarkCount = 1; //Mark3 rmData[2] = new SearchRegistrationMarksCommandData(); rmData[2].Rectangle = new LeadRect(7, 1073, 298 - 7, 1246 - 1073); rmData[2].MarkDetectedPoints = new LeadPoint[1]; rmData[2].Width = 31; rmData[2].Height = 29; rmData[2].Type = RegistrationMarkCommandType.TShape; rmData[2].MinimumScale = 90; rmData[2].MaximumScale = 110; rmData[2].SearchMarkCount = 1; SearchRegistrationMarksCommand command1 = new SearchRegistrationMarksCommand(rmData); command1.Run(image); if ((rmData[2].MarkDetectedCount != 1) || (rmData[1].MarkDetectedCount != 1) || (rmData[0].MarkDetectedCount != 1)) return; LeadPoint[] original = { new LeadPoint(81400, 11300), new LeadPoint(78600, 87400), new LeadPoint(14300, 115400) }; LeadPoint[] detected = { rmData[0].MarkDetectedPoints[0], rmData[1].MarkDetectedPoints[0], rmData[2].MarkDetectedPoints[0] }; //Find center of mass for detected registration marks in the transformed image LeadPoint[] transformed = CoreUtilities.GetRegistrationMarksCenterMass(image, detected); //Find transformation parameters TransformationParameters parameters = CoreUtilities.GetTransformationParameters(image, original, transformed); //Apply transformation parameters to correct the image ApplyTransformationParametersCommand applyCommand = new ApplyTransformationParametersCommand(parameters.XTranslation, parameters.YTranslation, parameters.Angle, parameters.XScale, parameters.YScale, ApplyTransformationParametersCommandFlags.Normal); applyCommand.Run(image); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; } |
SilverlightCSharp | Copy Code |
---|---|
SilverlightVB | Copy Code |
---|---|
- This method detects transformation parameters of the transformed image by comparing it with the reference image. The number of reference and detected points must be three.
- Use Leadtools.ImageProcessing.Core.CoreUtilities.GetRegistrationMarksCenterMass to fill the referencePoints array with the points representing the center of masses for each of the reference marks from the reference image.
- Fill the transformedPoints array by performing the following steps:
- Use SearchRegistrationMarksCommand to find the new positions for the reference marks.
- Using Leadtools.ImageProcessing.Core.CoreUtilities.GetRegistrationMarksCenterMass to fill the transformedPoints array with points representing the center of masses for each of the transformed reference marks.
- The properties of TransformationParameters which are: XTranslation, YTranslation, Angle, XScale and YScale are internally divided by 100. For example, an Angle of 500 would mean to rotate the image 5 degrees clockwise.
- The results of this method must be sent without any modification to the ApplyTransformationParameters method in order to correct the image.
- If you want to correct the image yourself, you have to perform the inverse operations in this order:
- Shift the image by (-TransformationParameters.XTranslation / 100, -TransformationParameters.YTranslation / 100) using Leadtools.ImageProcessing.Effects.CombineCommand
- Rotate without resizing by - (TransformationParameters.Angle)
- Resize using scaling factors of (100 / TransformationParameters.XScale, 100 / TransformationParameters.YScale) using Leadtools.ImageProcessing.SizeCommand or Leadtools.ImageProcessing.ResizeCommand.
- If you simply want to automatically straighten the image, use the DeskewCommand.
- This method supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
- This command does not support signed images.
Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)
Reference
CoreUtilities ClassCoreUtilities Members
Detecting Registration Marks
Leadtools.ImageProcessing.Effects.CombineCommand
Leadtools.ImageProcessing.RotateCommand
Leadtools.ImageProcessing.SizeCommand
Leadtools.ImageProcessing.ResizeCommand
IsRegistrationMark Method
SearchRegistrationMarksCommand Class
GetRegistrationMarksCenterMass Method