←Select platform

ApplyTransformationParametersCommand Constructor(int,int,int,int,int,ApplyTransformationParametersCommandFlags)

Summary
Initializes a new ApplyTransformationParametersCommand class object with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithXTranslation:(NSInteger)xTranslation yTranslation:(NSInteger)yTranslation angle:(NSInteger)angle xScale:(NSUInteger)xScale yScale:(NSUInteger)yScale flags:(LTApplyTransformationParametersCommandFlags)flags NS_DESIGNATED_INITIALIZER; 
public ApplyTransformationParametersCommand( 
   int xTranslation,  
   int yTranslation,  
   int angle,  
   int xScale,  
   int yScale,  
   int flags 
) 
public: 
ApplyTransformationParametersCommand(  
   int xTranslation, 
   int yTranslation, 
   int angle, 
   int xScale, 
   int yScale, 
   ApplyTransformationParametersCommandFlags flags 
) 
__init__(self,xTranslation,yTranslation,angle,xScale,yScale,flags) # Overloaded constructor 

Parameters

xTranslation
The amount of image translation along the x-axis (Width). This value is divided internally by 100. This value must be equal to the one returned from GetTransformationParameters.

yTranslation
The amount of image translation (in pixels) along the y-axis (Height). This value is divided internally by 100. This value must be equal to the one returned from GetTransformationParameters.

angle
Angle of rotation, in hundredths of degrees (+/-). This can be a number from 1 to 36,000. This value is divided internally by 100. A positive value means the image rotated in a clockwise rotation, while a negative value means the image rotated in a counter-clockwise rotation. This value must be equal to the one returned from GetTransformationParameters.

xScale
The amount of image x-axis (Width) scaling. This is a percentage value (divided internally by 100). This value must be equal to the one returned from GetTransformationParameters. This parameter accepts only positive values.

yScale
The amount of image y-axis (Height) scaling. This is a percentage value (divided internally by 100). This value must be equal to the one returned from GetTransformationParameters. This parameter accepts only positive values.

flags
Flag that specifies the behavior when resizing the image.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
 
 
public void GetTransformationParametersExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "RGSRef.cmp")); 
 
   // 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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.11.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.