Click or drag to resize

BorderRemovalCommand Class

An ImageCommand that removes solid borders from document images.
Inheritance Hierarchy

Namespace:  Atalasoft.Imaging.ImageProcessing.Document
Assembly:  Atalasoft.dotImage (in Atalasoft.dotImage.dll) Version: (.NET 4.5.2, x86)
public class BorderRemovalCommand : ImageCommand, 

The BorderRemovalCommand type exposes the following members.

Public methodBorderRemovalCommand
Creates a new instance of BorderRemovalCommand.
Public methodBorderRemovalCommand(BorderRemovalEdges)
Initializes a new instance of BorderRemovalCommand specifying the edges to remove.
Protected methodBorderRemovalCommand(SerializationInfo, StreamingContext)
Creates a new instance of BorderRemovalCommand from serialization information.
Public methodBorderRemovalCommand(BorderRemovalEdges, Double)
Initializes a new instance of BorderRemovalCommand specifying the edges to remove, and tolerance.
Public methodBorderRemovalCommand(BorderRemovalEdges, Double, Boolean)
Initializes a new instance of BorderRemovalCommand specifying the edges to remove, tolerance, and despeckling.
Public propertyApplyToAnyPixelFormat
Reports whether or not this command will be applied to any supplied PixelFormat image
(Inherited from ImageCommand.)
Public propertyCanApplyToAnyPixelFormat
Returns true if the command can be applied to any PixelFormat.
(Inherited from ImageCommand.)
Public propertyDespeckle
Gets or sets a value indicating if the calculated border will be despeckled first.
Public propertyEdges
Gets or sets a value indicating which of the 4 sides are to be removed.
Public propertyInPlaceProcessing
Gets a value indicating if the source image data is processed in-place as opposed to returning a new image.
(Inherited from ImageCommand.)
Public propertyProgress
Gets or sets the ProgressEventHandler delegate which can be used to view or cancel the progress of the current process.
(Inherited from ImageCommand.)
Public propertySupportedPixelFormats
Returns an array of PixelFormats supported by this command.
(Overrides ImageCommandSupportedPixelFormats.)
Public propertyTolerance
Gets or sets a value indicating the tolerance of the border detection.
Public methodApply
Apply the command to the given image.
(Inherited from ImageCommand.)
Public methodApplyToImage Obsolete.
Applies the command to the source AtalaImage.
(Inherited from ImageCommand.)
Protected methodConstructChangedSourceImage
The method is called by the default implementation of Apply. It determines if it is necessary to create a copy of the source image in a different pixel format and if so, determines the best new pixel format and allocates that image.
(Inherited from ImageCommand.)
Protected methodConstructFinalImage
Called by the default implementation of Apply, ConstructFinalImage constructs the image that will be used as the destination image for the command.
(Overrides ImageCommandConstructFinalImage(AtalaImage).)
Protected methodConstructImageResults
Constructs the results object for this command.
(Overrides ImageCommandConstructImageResults.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetBorder
Calculates the border of the image that is used in the BorderRemovalCommand to remove the borders.
Protected methodGetChangedPixelFormat
This method is called to change the pixel format of the source image.
(Inherited from ImageCommand.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetObjectData
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodImageCommandGetObjectData
Aggregates ImageCommand data into the supplied SerializationInfo object.
(Inherited from ImageCommand.)
Public methodIsPixelFormatSupported
Returns a value indicating if the specified pixel format is supported.
(Inherited from ImageCommand.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodPerformActualCommand
PerformActualCommand does the actual work of the image processing command.
(Overrides ImageCommandPerformActualCommand(AtalaImage, AtalaImage, Rectangle, ImageResults).)
Protected methodSelectBestAlternatePixelFormat
Choose the best pixel format to use for this command when the supplied source image's pixel format is unacceptable.
(Inherited from ImageCommand.)
Protected methodSelectPreferredPixelFormat
Chooses a pixel format that is preferred for this command.
(Overrides ImageCommandSelectPreferredPixelFormat(AtalaImage, PixelFormat, PixelFormat).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodVerifyImage
Verify the integrity of an AtalaImage.
(Inherited from ImageCommand.)
Protected methodVerifyProperties
Verify the integrity of properties in the command before processing an image.
(Overrides ImageCommandVerifyProperties(AtalaImage).)

This command can be used to remove black solid borders from the edges of images. A Tolerance of 0 will only work with perfect solid borders. Use a tolerance between 0 and 100 to account for minor noise in the border. Set Edges is true, the image will be despeckled prior to calculating the border, only if the image is binary. Note that the image that's returned from Apple will not be despeckled, only the image used in the calculation.

To calculate the border of the image, without cropping, use the GetBorder(AtalaImage) method. GetBorder ignores the Edges property and returns the border from all sides.

Dim cmd As New BorderRemovalCommand()
Dim results As BorderRemovalResults = CType(cmd.Apply(sourceImage), BorderRemovalCommandResults)
Dim newImage As AtalaImage = results.Image
Dim borderRect As Rectangle = results.Border
If (Not results.IsImageSourceImage) Then
 sourceImage.Dispose() 'free memory
End If
C# (C#)
BorderRemovalCommand cmd = new BorderRemovalCommand();  
BorderRemovalResults results = (BorderRemovalCommandResults)cmd.Apply(sourceImage);  
AtalaImage newImage = results.Image; 
Rectangle borderRect = results.Border; 
if (!results.IsImageSourceImage)  
  sourceImage.Dispose(); //free memory
See Also