←Select platform

DotRemoveCommand Class

Summary
Finds and removes dots and specks of various sizes. This method is available in the Document/Medical Toolkits.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public class DotRemoveCommand : RasterCommand 
@interface LTDotRemoveCommand : LTRasterCommand 
public class DotRemoveCommand 
    extends RasterCommand 
public ref class DotRemoveCommand : public RasterCommand   
class DotRemoveCommand(RasterCommand): 
Remarks
  • This method finds and removes dots, specks, and blobs of various sizes in 1-bit documents. The dots, specks, and blobs may or may not be all black. The behavior of this method can be modified by using an Event Handler that handles the DotRemoveCommandEventArgs.
  • This method works only on 1-bit black and white images.
  • If a region is selected, only the selected region will be changed by this method. If no region is selected, the whole image will be processed.
  • This command does not support signed data images.
  • This command does not support 32-bit grayscale images.

For more information, refer to Cleaning Up 1-Bit Images.

Dot Remove Function - Before

Dot Remove Function - Before

Dot Remove Function - After

Dot Remove Function - After

View additional platform support for this Dot Remove function.

Example

Run the DotRemoveCommand on an image.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void DotRemoveCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Clean.tif")); 
 
   // Prepare the command 
   DotRemoveCommand command = new DotRemoveCommand(); 
   command.DotRemove += new EventHandler<DotRemoveCommandEventArgs>(DotRemoveEvent_S1); 
   command.Flags = DotRemoveCommandFlags.UseSize; 
   command.MaximumDotHeight = 10; 
   command.MaximumDotWidth = 10; 
   command.MinimumDotHeight = 1; 
   command.MinimumDotWidth = 1; 
 
   command.Run(image); 
 
} 
 
private void DotRemoveEvent_S1(object sender, DotRemoveCommandEventArgs e) 
{ 
   System.Diagnostics.Debug.WriteLine("Size   " + e.BoundingRectangle.Width + e.BoundingRectangle.Height + "Bounds" 
      + e.BoundingRectangle.Left + "," + e.BoundingRectangle.Top + "," + e.BoundingRectangle.Right + "," + e.BoundingRectangle.Bottom + "," 
      + "     WhiteCount" + e.WhiteCount + "    BlackCount" + e.BlackCount, "DotRemove Event"); 
 
   //Do not remove the speck if it contains any white pixels 
   if (e.WhiteCount > 0) 
   { 
      e.Status = RemoveStatus.NoRemove; 
   } 
   else 
   { 
      e.Status = RemoveStatus.Remove; 
   } 
} 
 
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.