Leadtools.ImageProcessing.Core Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AutoCropRectangleCommand Constructor(Int32)
See Also  Example
Leadtools.ImageProcessing.Core Namespace > AutoCropRectangleCommand Class > AutoCropRectangleCommand Constructor : AutoCropRectangleCommand Constructor(Int32)



threshold
Delta value for detecting blank space. Starting at each edge of the image and evaluating toward the center, any change in intensity that is less than or equal to this parameter is considered blank space. Valid values are 0 to 255.
Initializes a new AutoCropRectangleCommand class object with explicit parameters.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal threshold As Integer _
)
Visual Basic (Usage)Copy Code
Dim threshold As Integer
 
Dim instance As AutoCropRectangleCommand(threshold)
C# 
public AutoCropRectangleCommand( 
   int threshold
)
C++/CLI 
public:
AutoCropRectangleCommand( 
   int threshold
)

Parameters

threshold
Delta value for detecting blank space. Starting at each edge of the image and evaluating toward the center, any change in intensity that is less than or equal to this parameter is considered blank space. Valid values are 0 to 255.

Example

Run the AutoCropRectangleCommand on an image to get the AutoCrop Rectangle.

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

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

   ' Prepare the command
   Dim threshold As Integer = 0
   Try
      Dim command As AutoCropRectangleCommand
      command = New AutoCropRectangleCommand(threshold)
      ' Get the Rectangle for AutoCrop with tolerance = threshold passes by the user.
      command.Run(leadImage)
      MessageBox.Show("Left = " + command.Rectangle.Left.ToString() + Chr(13) + "Top = " + command.Rectangle.Top.ToString() + Chr(13) + "Right = " + command.Rectangle.Right.ToString() + Chr(13) + "Bottom = " + command.Rectangle.Bottom.ToString())
   Catch e As Exception
      MessageBox.Show(e.Message)
   End Try

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

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Master.jpg"); 
 
   // Prepare the command 
   int threshold = 0; 
   try 
   { 
      AutoCropRectangleCommand command = new AutoCropRectangleCommand(threshold); 
      // Get the Rectangle for AutoCrop with tolerance = threshold passes by the user. 
      command.Run(image); 
      MessageBox.Show("Left = " + command.Rectangle.Left.ToString() + "\n" +  
         "Top = " + command.Rectangle.Top.ToString() + "\n" + 
         "Right = " + command.Rectangle.Right.ToString() + "\n" +  
         "Bottom = " + command.Rectangle.Bottom.ToString()); 
   } 
   catch(Exception exception) 
   { 
      MessageBox.Show(exception.Message); 
   } 
 
   RasterCodecs.Shutdown(); 
}

Remarks

For more information, refer to Introduction to Image Processing With LEADTOOLS.

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