←Select platform

SubtractBackgroundCommand Constructor(int,SubtractBackgroundCommandType,int,SubtractBackgroundCommandFlags)

Summary
Initializes a new SubtractBackgroundCommand class object with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
- (instancetype)initWithRollingBall:(NSUInteger)rollingBall shrinkingSize:(LTSubtractBackgroundCommandType)shrinkingSize brightnessFactor:(NSUInteger)brightnessFactor flags:(LTSubtractBackgroundCommandFlags)flags NS_DESIGNATED_INITIALIZER; 
public SubtractBackgroundCommand( 
   int rollingBall,  
   SubtractBackgroundCommandType shrinkingSize,  
   int brightnessFactor,  
   int flags 
) 
__init__(self,rollingBall,shrinkingSize,brightnessFactor,flags) # Overloaded constructor 

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#
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:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.11.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Core Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.