Leadtools.ImageProcessing.Core Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
DeskewExtendedCommand Class
See Also  Members   Example 
Leadtools.ImageProcessing.Core Namespace : DeskewExtendedCommand Class



Rotates the specified image to straighten it. This command is typically used to automatically straighten scanned images. This method is available in the Document\Medical toolkits.

Syntax

Visual Basic (Declaration) 
Public Class DeskewExtendedCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As DeskewExtendedCommand
C# 
public class DeskewExtendedCommand : RasterCommand, IRasterCommand  
C++/CLI 
public ref class DeskewExtendedCommand : public RasterCommand, IRasterCommand  

Example

Run the DeskewExtendedCommand on an image and applies the Deskew Extended filter.

Visual BasicCopy Code
Public Sub DeskewExtendedCommandExample()
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Clean.tif")

   ' Prepare the command
   Dim command As DeskewExtendedCommand = New DeskewExtendedCommand
   Dim fillColor As New RasterColor(0, 0, 0)

   command.AngleRange = 1000
   command.AngleResolution = 2
   command.FillColor = fillColor
   command.Flags = DeskewExtendedCommandFlags.DeskewImage Or DeskewExtendedCommandFlags.DoNotFillExposedArea Or DeskewExtendedCommandFlags.RotateLinear Or DeskewExtendedCommandFlags.DocumentImage
   command.Run(leadImage)

   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void DeskewExtendedCommandExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Clean.tif"); 
 
   // Prepare the command 
   DeskewExtendedCommand command = new DeskewExtendedCommand(); 
   RasterColor fillColor = new RasterColor(0, 0, 0); 
 
   command.AngleRange = 1000; 
   command.AngleResolution = 2; 
   command.FillColor = fillColor; 
   command.Flags = DeskewExtendedCommandFlags.DeskewImage | DeskewExtendedCommandFlags.DoNotFillExposedArea | DeskewExtendedCommandFlags.RotateLinear | DeskewExtendedCommandFlags.DocumentImage; 
   command.Run(image); 
 
   RasterCodecs.Shutdown(); 
}

Remarks

  • Like the DeskewCommand, you can use this command class to automatically straighten scanned documents. This class extends the DeskewCommand class to increase the possible deskew angle (from 20 degrees to 45 degrees in either direction). In addition it adds the capability to specify the resolution of the rotation step.
  • If the Flags property contains DeskewExtendedCommandFlags.ReturnAngleOnly, the method will update the Angle with the deskew angle without rotating the image.
  • This command includes an option to skip deskewing if the angle is very small.
  • The calculated rotation is limited to 45 degrees in either direction. This method is intended for images, such as scanned documents, that are mainly horizontal lines of text. The results are less predictable with other types of images.
  • 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 method does not support signed data images.
  • This command does not support 32-bit grayscale images.
For more information, refer to Removing Noise.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Core.DeskewExtendedCommand

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