←Select platform

SubtractBackgroundCommand Constructor(int,SubtractBackgroundCommandType,int,SubtractBackgroundCommandFlags)

Summary

Initializes a new SubtractBackgroundCommand class object with explicit parameters.

Syntax

C#
VB
Java
Objective-C
C++
- (instancetype)initWithRollingBall:(NSUInteger)rollingBall 
                      shrinkingSize:(LTSubtractBackgroundCommandType)shrinkingSize 
                   brightnessFactor:(NSUInteger)brightnessFactor 
                              flags:(LTSubtractBackgroundCommandFlags)flags 
             
public SubtractBackgroundCommand( 
   int rollingBall,  
   SubtractBackgroundCommandType shrinkingSize,  
   int brightnessFactor,  
   int flags 
) 
             

Parameters

rollingBall
The radius (in pixels) of the ball that will roll over the entire image to determine the background. Recommended value is 50. This parameter accepts only positive values.

shrinkingSize
Shrink size ratio used to minimize the image internally in order to increase the speed with little loss of accuracy.

brightnessFactor
Brightness factor for increasing or decreasing the brightness of the image. Valid values range from 0 - 400. If you pass 100 the brightness remains unchanged. Lower values darken the image while higher values lighten the image.

flags
Flags that indicate whether the background is darker than the foreground, and whether to show the objects without the background. You must select one from each group.

Example

Run the SubtractBackgroundCommand on an image.

C#
VB
Silverlight C#
Silverlight VB
using Leadtools; 
using Leadtools.ImageProcessing; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void SubtractBackgroundConstructorExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, @"ImageProcessingDemo\Image4.Tif")); 
 
   GrayscaleCommand grayScaleCommand = new GrayscaleCommand(8); 
   grayScaleCommand.Run(image); 
 
   // Prepare the command 
   SubtractBackgroundCommand command = new SubtractBackgroundCommand(799, SubtractBackgroundCommandType.DependOnRollingBallSize, 178, SubtractBackgroundCommandFlags.BackgroundIsDarker); 
 
   // Apply Subtract Background effect on the image. 
   command.Run(image); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.ImageProcessing 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.Core 
      Leadtools.Examples.Support.SetLicense() 
 
Public Sub SubtractBackgroundConstructorExample() 
   Dim codecs As New RasterCodecs() 
   codecs.ThrowExceptionsOnInvalidImages = True 
 
   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\\Image4.Tif")) 
 
   Dim grayScaleCommand As GrayscaleCommand = New GrayscaleCommand(8) 
   grayScaleCommand.Run(leadImage) 
 
   ' Prepare the command 
   Dim command As SubtractBackgroundCommand = New SubtractBackgroundCommand(799, SubtractBackgroundCommandType.DependOnRollingBallSize, 178, SubtractBackgroundCommandFlags.BackgroundIsDarker) 
   ' Apply Subtract Background effect on the image. 
   command.Run(leadImage) 
 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
using Leadtools; 
using Leadtools.Examples; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void SubtractBackgroundConstructorExample(RasterImage image, Stream outStream) 
{ 
   // Prepare the command 
   SubtractBackgroundCommand command = new SubtractBackgroundCommand(50, SubtractBackgroundCommandType.DependOnRollingBallSize, 100, SubtractBackgroundCommandFlags.BackgroundIsDarker); 
   // Apply Subtract Background effect on the image. 
   command.Run(image); 
   // Save result image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); 
   image.Dispose(); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.Core 
 
Public Sub SubtractBackgroundConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream) 
   ' Prepare the command 
   Dim command As SubtractBackgroundCommand = New SubtractBackgroundCommand(50, SubtractBackgroundCommandType.DependOnRollingBallSize, 100, 
                                                                            SubtractBackgroundCommandFlags.BackgroundIsDarker) 
   ' Apply Subtract Background effect on the image. 
   command.Run(image) 
   ' Save result image 
   Dim codecs As RasterCodecs = New RasterCodecs() 
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24) 
   image.Dispose() 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly