LEADTOOLS Image Processing (Leadtools.ImageProcessing.Core assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
DigitalSubtractCommand Class
See Also  Members  
Leadtools.ImageProcessing.Core Namespace : DigitalSubtractCommand Class



Subtracts the live image from the mask image to show the differences between the two images. This method is available in the Medical and above. Supported in Silverlight, Windows Phone 7

Object Model

DigitalSubtractCommand Class

Syntax

Visual Basic (Declaration) 
Public Class DigitalSubtractCommand 
   Inherits Leadtools.ImageProcessing.RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As DigitalSubtractCommand
C# 
public class DigitalSubtractCommand : Leadtools.ImageProcessing.RasterCommand, IRasterCommand  
C++/CLI 
public ref class DigitalSubtractCommand : public Leadtools.ImageProcessing.RasterCommand, IRasterCommand  

Example

Run the DigitalSubtractCommand on an image.

Visual BasicCopy Code
Public Sub DigitalSubtractCommandExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

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

   ' Prepare the command
   Dim MaskImage As RasterImage
   MaskImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\Image3.cmp"), 4, CodecsLoadByteOrder.Bgr, 1, 1)

   Dim command As DigitalSubtractCommand = New DigitalSubtractCommand
   command.Flags = DigitalSubtractCommandFlags.ContrastEnhancement
   command.MaskImage = MaskImage
   command.Run(leadImage)

End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void DigitalSubtractCommandExample()
   {
      // Load an image
      RasterCodecs codecs = new RasterCodecs();
      codecs.ThrowExceptionsOnInvalidImages = true;

      RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"));

      // Prepare the command
      RasterImage MaskImage;
      MaskImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"), 4, CodecsLoadByteOrder.Bgr, 1, 1);

      DigitalSubtractCommand command = new DigitalSubtractCommand();
      command.Flags = DigitalSubtractCommandFlags.ContrastEnhancement;
      command.MaskImage = MaskImage;
      command.Run(image);

   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void DigitalSubtractCommandExample(RasterImage image, RasterImage maskImage, Stream outStream)
{
   // Prepare the command
   DigitalSubtractCommand command = new DigitalSubtractCommand();
   command.Flags = DigitalSubtractCommandFlags.ContrastEnhancement;
   command.MaskImage = maskImage;
   command.Run(image);
   // Save result image
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);
   image.Dispose();
   maskImage.Dispose();
}
SilverlightVBCopy Code
Public Sub DigitalSubtractCommandExample(ByVal image As RasterImage, ByVal maskImage As RasterImage, ByVal outStream As Stream)
   ' Prepare the command
   Dim command As DigitalSubtractCommand = New DigitalSubtractCommand()
   command.Flags = DigitalSubtractCommandFlags.ContrastEnhancement
   command.MaskImage = maskImage
   command.Run(image)
   ' Save result image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
   image.Dispose()
   maskImage.Dispose()
End Sub

Remarks

  • Performs a digital subtraction between two images. The resulting image may be enhanced using the Flags options. Digital subtraction is mainly used to show the differences or the changes between two images. For the process to be meaningful both images should be related to each other. Digital Subtraction Angiography (DSA) is a practical example of digital subtraction.
  • Digital Subtraction Angiography (DSA) and Quality Control (QC) are both major fields that use image subtraction. An example of DSA is explained below.
  • DSA is a technology used for the visualization of blood vessels in the human body. A mask image is obtained using X-ray film of the body part of interest. Then vessels of that part are injected using a contrast medium. A sequence of images is taken after the injection. These are called live images. After applying subtraction between the mask and live images the resulting images are images that show the passage of the contrast medium in the vessels.
  • Both the affected image and MaskImage should have the same bits per pixel, number of channels and image dimensions; otherwise the method will return an error code.
  • If the DigitalSubtractCommandFlags.ContrastEnhancement flag is set then the contrast of the subtracted image will be enhanced.
  • If the DigitalSubtractCommandFlags.OptimizeRange flag is set then the tonal range of the subtracted image will be optimized. That is, the image intensity will be distributed among the full image intensity range.
  • This class supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available only in the Document/Medical toolkits.
  • This command does not support 32-bit grayscale images.
  • All images must be signed or unsigned.
For more information, refer to Introduction to Image Processing With LEADTOOLS.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Core.DigitalSubtractCommand

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also