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




flags
Flag that determines the behavior of the border removal process.
border
Flag that indicates which border to remove.
percent
Percent of the image dimension in which the border will be found. For most images, use 20. For example, if an image is 200 pixels wide, Percent is set to 20 and Border is set to BorderRemoveBorderFlags.Left, then the left border will be found in the area between the left edge of the image and a line 40 pixels from the left edge. If the border is closer to the edge of the image, use a smaller value. If the border is farther from the edge, use a larger value.
whiteNoiseLength
Amount of white noise tolerated when determining the border. The units are in pixels. Values of 0 to 10 are sufficient for most images.
variance
Amount of variance tolerated in the border. If the border varies significantly in thickness, you should use a higher value for Variance. Range is 0 to 10.
Initializes a new BorderRemoveCommand class object with explicit parameters.

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal flags As BorderRemoveCommandFlags, _
   ByVal border As BorderRemoveBorderFlags, _
   ByVal percent As Integer, _
   ByVal whiteNoiseLength As Integer, _
   ByVal variance As Integer _
)
Visual Basic (Usage)Copy Code
Dim flags As BorderRemoveCommandFlags
Dim border As BorderRemoveBorderFlags
Dim percent As Integer
Dim whiteNoiseLength As Integer
Dim variance As Integer
 
Dim instance As BorderRemoveCommand(flags, border, percent, whiteNoiseLength, variance)
C# 
public BorderRemoveCommand( 
   BorderRemoveCommandFlags flags,
   BorderRemoveBorderFlags border,
   int percent,
   int whiteNoiseLength,
   int variance
)
Managed Extensions for C++ 
public: BorderRemoveCommand( 
   BorderRemoveCommandFlags flags,
   BorderRemoveBorderFlags border,
   int percent,
   int whiteNoiseLength,
   int variance
)
C++/CLI 
public:
BorderRemoveCommand( 
   BorderRemoveCommandFlags flags,
   BorderRemoveBorderFlags border,
   int percent,
   int whiteNoiseLength,
   int variance
)

Parameters

flags
Flag that determines the behavior of the border removal process.
border
Flag that indicates which border to remove.
percent
Percent of the image dimension in which the border will be found. For most images, use 20. For example, if an image is 200 pixels wide, Percent is set to 20 and Border is set to BorderRemoveBorderFlags.Left, then the left border will be found in the area between the left edge of the image and a line 40 pixels from the left edge. If the border is closer to the edge of the image, use a smaller value. If the border is farther from the edge, use a larger value.
whiteNoiseLength
Amount of white noise tolerated when determining the border. The units are in pixels. Values of 0 to 10 are sufficient for most images.
variance
Amount of variance tolerated in the border. If the border varies significantly in thickness, you should use a higher value for Variance. Range is 0 to 10.

Example

Visual BasicCopy Code
ImageProcessing.Core.BorderRemoveCommand.BorderRemoveConstructor
   Public WithEvents borderRemoveConstructorCallback As BorderRemoveCommand
   Public Sub BorderRemoveConstructorExample()
      RasterCodecs.Startup()
      Dim codecs As New RasterCodecs()
      codecs.ThrowExceptionsOnInvalidImages = True

      Dim leadImage As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Clean.tif")

      ' Prepare the command
      borderRemoveConstructorCallback = New BorderRemoveCommand(BorderRemoveCommandFlags.UseVariance Or BorderRemoveCommandFlags.CallBackRegion, BorderRemoveBorderFlags.All, 20, 9, 3)
      borderRemoveConstructorCallback.Run(leadImage)

      RasterCodecs.Shutdown()
   End Sub

   Private Sub BorderRemoveCommand_BorderRemove_S2(ByVal sender As Object, ByVal e As BorderRemoveCommandEventArgs) Handles borderRemoveConstructorCallback.BorderRemove
      Dim ee As BorderRemoveCommandEventArgs = New BorderRemoveCommandEventArgs(e.Image, e.Region, BorderRemoveBorderFlags.All, e.BoundingRectangle)
      e.Status = RemoveStatus.NoRemove

      If Not (e.Region Is Nothing) Then
         e.Image.AddGdiPlusRegionToRegion(Nothing, e.Region, RasterRegionCombineMode.Set)
         Dim command As InvertCommand = New InvertCommand
         command.Run(e.Image)
         e.Image.MakeRegionEmpty()
      End If
   End Sub
C#Copy Code
ImageProcessing.Core.BorderRemoveCommand.BorderRemoveConstructor 
      public void BorderRemoveConstructorExample() 
      { 
         // Load an image 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
         codecs.ThrowExceptionsOnInvalidImages = true; 
 
         RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Clean.tif"); 
 
         // Prepare the command 
         BorderRemoveCommand command = new BorderRemoveCommand( BorderRemoveCommandFlags.UseVariance | BorderRemoveCommandFlags.CallBackRegion, BorderRemoveBorderFlags.All, 20, 9, 3); 
         command.BorderRemove += new EventHandler<BorderRemoveCommandEventArgs>(command_BorderRemove_S2); 
         command.Run(image); 
 
         RasterCodecs.Shutdown(); 
      } 
 
      private void command_BorderRemove_S2(object sender, BorderRemoveCommandEventArgs e) 
      { 
         BorderRemoveCommandEventArgs ee = new BorderRemoveCommandEventArgs(e.Image, e.Region, BorderRemoveBorderFlags.All, e.BoundingRectangle); 
         e.Status = RemoveStatus.NoRemove; 
 
         if(e.Region != null) 
         { 
            e.Image.AddGdiPlusRegionToRegion(null, e.Region, RasterRegionCombineMode.Set); 
            InvertCommand command = new InvertCommand(); 
            command.Run(e.Image); 
            e.Image.MakeRegionEmpty(); 
         } 
      }

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