Core utility class.
Syntax
Visual Basic (Declaration) | |
---|
Public NotInheritable Class CoreUtilities |
C# | |
---|
public sealed class CoreUtilities |
Managed Extensions for C++ | |
---|
public __gc __sealed class CoreUtilities |
C++/CLI | |
---|
public ref class CoreUtilities sealed |
Example
Visual Basic | Copy Code |
---|
ImageProcessing.Core.CoreUtilities.GetTransformationParameters
Public Sub GetTransformationParametersExample()
RasterCodecs.Startup()
Dim codecs As New RasterCodecs()
codecs.ThrowExceptionsOnInvalidImages = True
Dim leadImage As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Master.jpg")
Dim rmData(2) As SearchRegistrationMarksCommandData
rmData(0) = New SearchRegistrationMarksCommandData
rmData(0).Rectangle = New Rectangle(680, 20, 941 - 680, 218 - 20)
Dim pt0(0) As Point
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
rmData(1) = New SearchRegistrationMarksCommandData
rmData(1).Rectangle = New Rectangle(665, 790, 899 - 665, 961 - 790)
Dim pt1(0) As Point
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
rmData(2) = New SearchRegistrationMarksCommandData
rmData(2).Rectangle = New Rectangle(7, 1073, 298 - 7, 1246 - 1073)
Dim pt2(0) As Point
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 Point = _
{ _
New Point(81400, 11300), _
New Point(78600, 87400), _
New Point(14300, 115400) _
}
Dim detected() As Point = _
{ _
rmData(0).MarkDetectedPoints(0), _
rmData(1).MarkDetectedPoints(0), _
rmData(2).MarkDetectedPoints(0) _
}
Dim transformed() As Point = CoreUtilities.GetRegistrationMarksCenterMass(leadImage, detected)
Dim parameters As TransformationParameters = CoreUtilities.GetTransformationParameters(leadImage, original, transformed)
Dim applyCommand As New ApplyTransformationParametersCommand(parameters.XTranslation, parameters.YTranslation, parameters.Angle, parameters.XScale, parameters.YScale, ApplyTransformationParametersCommandFlags.Normal)
applyCommand.Run(leadImage)
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
ImageProcessing.Core.CoreUtilities.GetTransformationParameters public void GetTransformationParametersExample() { // Load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Master.jpg"); // Prepare the command SearchRegistrationMarksCommandData[] rmData = new SearchRegistrationMarksCommandData[3]; //Mark1 rmData[0] = new SearchRegistrationMarksCommandData(); rmData[0].Rectangle = new Rectangle(680, 20, 941 - 680, 218 - 20); rmData[0].MarkDetectedPoints = new Point[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 Rectangle(665, 790, 899 - 665, 961 - 790); rmData[1].MarkDetectedPoints = new Point[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 Rectangle(7, 1073, 298 - 7, 1246 - 1073); rmData[2].MarkDetectedPoints = new Point[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; Point[] original = { new Point(81400, 11300), new Point(78600, 87400), new Point(14300, 115400) }; Point[] 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 Point[] 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); RasterCodecs.Shutdown(); } |
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also