←Select platform

ManualPerspectiveCorrectionCommand Class

Summary
Corrects the view perspective of the RasterImage.
Syntax
C#
VB
Objective-C
C++
Java
public class ManualPerspectiveCorrectionCommand : RasterCommand, IDestDataCommand 
Public Class ManualPerspectiveCorrectionCommand 
   Inherits RasterCommand 
@interface LTKernelManualPerspectiveCorrectionCommand : LTRasterCommand 
public class ManualPerspectiveCorrectionCommand extends RasterCommand 
public ref class ManualPerspectiveCorrectionCommand : public RasterCommand 
Remarks
  • Typically, this command is used as a preprocessing step when working with images from digital cameras. It changes the image based on a view perspective equation.
  • Use the Run method to fix the distorted image. Obtain the deskewed image from the DestinationImage property.
  • After the command is run, the resulting image will be in the ManualPerspectiveCorrectionCommand.DestinationImage property. This property will hold a copy of the image, so the user is responsible for freeing this image after using it.
  • This function can only process entire images. It does not support regions.
  • This command 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 supports unsigned data images, but not signed ones.
  • This command does not support 32-bit grayscale images.

Note: All RasterCommands in this assembly modify the underlying properties of the input RasterImage, including but not limited to:

  • BitsPerPixel
  • Data
  • IsMirrored

If you wish to avoid RasterImage property fidelity loss, pass a clone of your RasterImage to all RasterCommands in this assembly.

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Kernel; 
 
public void ManualPerspectiveCorrectionCommandExample() 
{ 
   using (RasterCodecs codecs = new RasterCodecs()) 
   { 
      // Load an image 
      using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PerspectiveDeskew.jpg"))) 
      { 
         //Prepare the command 
         ManualPerspectiveCorrectionCommand command = new ManualPerspectiveCorrectionCommand(); 
 
         //The four corners of the polygon (Can be retrieved using DetectDocumentCommand) 
         command.InputPoints[0] = new LeadPoint(131, 193); 
         command.InputPoints[1] = new LeadPoint(456, 151); 
         command.InputPoints[2] = new LeadPoint(535, 282); 
         command.InputPoints[3] = new LeadPoint(124, 354); 
 
         // Set mapping points 
         command.MappingPoints[0] = new LeadPoint(0, 0); 
         command.MappingPoints[1] = new LeadPoint(610, 0); 
         command.MappingPoints[2] = new LeadPoint(610, 421); 
         command.MappingPoints[3] = new LeadPoint(0, 421); 
 
         // Run the command and save the result 
         command.Run(image); 
         codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24); 
 
         command.DestinationImage.Dispose(); 
      } 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.Kernel 
 
Public Sub ManualPerspectiveCorrectionCommandExample() 
   Using codecs As RasterCodecs = New RasterCodecs() 
      Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "PerspectiveDeskew.jpg")) 
         ' Prepare the command 
         Dim command As ManualPerspectiveCorrectionCommand = New ManualPerspectiveCorrectionCommand() 
 
         ' The four corners of the polygon (Can be retrieved using DetectDocumentCommand) 
         command.InputPoints(0) = New LeadPoint(131, 193) 
         command.InputPoints(1) = New LeadPoint(456, 151) 
         command.InputPoints(2) = New LeadPoint(535, 282) 
         command.InputPoints(3) = New LeadPoint(124, 354) 
 
         ' Set mapping points 
         command.MappingPoints(0) = New LeadPoint(0, 0) 
         command.MappingPoints(1) = New LeadPoint(610, 0) 
         command.MappingPoints(2) = New LeadPoint(610, 421) 
         command.MappingPoints(3) = New LeadPoint(0, 421) 
 
         ' Run the command And save the result 
         command.Run(image) 
         codecs.Save(command.DestinationImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.bmp"), RasterImageFormat.Bmp, 24) 
 
         command.DestinationImage.Dispose() 
 
      End Using 
   End Using 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

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

Leadtools.ImageProcessing.Kernel Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.