LEADTOOLS Image Processing (Leadtools.ImageProcessing.Core assembly)

BorderRemoveCommand Constructor(BorderRemoveCommandFlags,BorderRemoveBorderFlags,Int32,Int32,Int32)

Show in webframe
Example 







Flag that determines the behavior of the border removal process.
Flag that indicates which border to remove.
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.
Amount of white noise tolerated when determining the border. The units are in pixels. Values of 0 to 10 are sufficient for most images.
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
public BorderRemoveCommand( 
   BorderRemoveCommandFlags flags,
   BorderRemoveBorderFlags border,
   int percent,
   int whiteNoiseLength,
   int variance
)
'Declaration
 
Public Function New( _
   ByVal flags As BorderRemoveCommandFlags, _
   ByVal border As BorderRemoveBorderFlags, _
   ByVal percent As Integer, _
   ByVal whiteNoiseLength As Integer, _
   ByVal variance As Integer _
)
'Usage
 
Dim flags As BorderRemoveCommandFlags
Dim border As BorderRemoveBorderFlags
Dim percent As Integer
Dim whiteNoiseLength As Integer
Dim variance As Integer
 
Dim instance As New BorderRemoveCommand(flags, border, percent, whiteNoiseLength, variance)
public BorderRemoveCommand( 
   BorderRemoveCommandFlags flags,
   BorderRemoveBorderFlags border,
   int percent,
   int whiteNoiseLength,
   int variance
)
- (id)initWithFlags:(LTBorderRemoveCommandFlags)flags 
             border:(LTBorderRemoveBorderFlags)border 
            percent:(int)percent 
   whiteNoiseLength:(int)whiteNoiseLength 
           variance:(int)variance;
            
public BorderRemoveCommand(
   int flags, 
   int border, 
   int percent, 
   int whiteNoiseLength, 
   int variance
)
            
function BorderRemoveCommand( 
   flags ,
   border ,
   percent ,
   whiteNoiseLength ,
   variance 
)
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
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color

Public WithEvents borderRemoveConstructorCallback As BorderRemoveCommand
Public Sub BorderRemoveConstructorExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Clean.tif"))

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

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.SetRegion(Nothing, e.Region, RasterRegionCombineMode.Set)
      Dim command As InvertCommand = New InvertCommand
      command.Run(e.Image)
      e.Image.MakeRegionEmpty()
   End If
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;

public void BorderRemoveConstructorExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;

   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "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);

}

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.SetRegion(null, e.Region, RasterRegionCombineMode.Set);
      InvertCommand command = new InvertCommand();
      command.Run(e.Image);
      e.Image.MakeRegionEmpty();
   }
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
function BorderRemoveConstructorExample()
{
   var codecs = new Leadtools.Codecs.RasterCodecs();
   codecs.throwExceptionsOnInvalidImages = true;

   // Load the image
   var srcFileName = "Assets\\Clean.tif";
   return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      // Prepare the command
      with (Leadtools.ImageProcessing.Core) {
         var command = new BorderRemoveCommand( BorderRemoveCommandFlags.useVariance | BorderRemoveCommandFlags.callBackRegion, BorderRemoveBorderFlags.all, 20, 9, 3);
         command.addEventListener("borderremove", command_BorderRemove_S2);
         command.run(image);
      }
   });
}

function command_BorderRemove_S2(e)
{
   with (Leadtools.ImageProcessing.Core) {
      e.status = RemoveStatus.noRemove;

      if (e.region != null) {
         e.image.setRegion(null, e.region, Leadtools.RasterRegionCombineMode.set);
         with (Leadtools.ImageProcessing.Color) {
            var command = new InvertCommand();
            command.run(e.image);
         }
         e.image.makeRegionEmpty();
      }
   }
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;

      
public async Task BorderRemoveConstructorExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   // Load the image
   string srcFileName = @"Assets\Clean.tif";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // 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);

}

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.SetRegion(null, e.Region, RasterRegionCombineMode.Set);
      InvertCommand command = new InvertCommand();
      command.Run(e.Image);
      e.Image.MakeRegionEmpty();
   }
}
using Leadtools;
using Leadtools.Examples;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;

public void BorderRemoveConstructorExample(RasterImage image, Stream outStream)
{
   // 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);
   // Save result image
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1);
   image.Dispose();
}

private void command_BorderRemove_S2(object sender, BorderRemoveCommandEventArgs e)
{
   BorderRemoveCommandEventArgs ee = new BorderRemoveCommandEventArgs(e.Image,null, BorderRemoveBorderFlags.All, e.BoundingRectangle);
   e.Status = RemoveStatus.NoRemove;

}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing.Core

Public Sub BorderRemoveConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream)
   ' Prepare the command
   Dim command As BorderRemoveCommand = New BorderRemoveCommand(BorderRemoveCommandFlags.UseVariance Or BorderRemoveCommandFlags.CallBackRegion, _
                                                                BorderRemoveBorderFlags.All, 20, 9, 3)
   AddHandler command.BorderRemove, AddressOf command_BorderRemove_S2
   command.Run(image)
   ' Save result image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, outStream, RasterImageFormat.CcittGroup4, 1)
   image.Dispose()
End Sub

Private Sub command_BorderRemove_S2(ByVal sender As Object, ByVal e As BorderRemoveCommandEventArgs)
   Dim ee As BorderRemoveCommandEventArgs = New BorderRemoveCommandEventArgs(e.Image,Nothing, BorderRemoveBorderFlags.All, e.BoundingRectangle)
   e.Status = RemoveStatus.NoRemove

End Sub
Requirements

Target Platforms

See Also

Reference

BorderRemoveCommand Class
BorderRemoveCommand Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.