Leadtools.ImageProcessing.Color Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.10
SampleTargetCommand Class
See Also  Members   Example 




Corrects color values by shifting the sample colors to the target colors. This command is available in the Raster Pro and above toolkits.

Syntax

Visual Basic (Declaration) 
Public Class SampleTargetCommand 
   Inherits RasterCommand
   Implements IRasterCommand 
Visual Basic (Usage)Copy Code
Dim instance As SampleTargetCommand
C# 
public class SampleTargetCommand : RasterCommand, IRasterCommand  
Managed Extensions for C++ 
public __gc class SampleTargetCommand : public RasterCommand, IRasterCommand  
C++/CLI 
public ref class SampleTargetCommand : public RasterCommand, IRasterCommand  

Example

Visual BasicCopy Code
ImageProcessing.SpecialEffects.SampleTargetCommand
   Public Sub SampleTargetCommandExample()
      RasterCodecs.Startup()
      Dim codecs As New RasterCodecs()
      codecs.ThrowExceptionsOnInvalidImages = True

      Dim leadImage As RasterImage = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Master.jpg")

      ' Prepare the command
      Dim command As SampleTargetCommand = New SampleTargetCommand
      command.SampleColor = New RasterColor(50, 100, 150)
      command.TargetColor = New RasterColor(60, 90, 150)
      command.Flags = SampleTargetCommandFlags.Red Or SampleTargetCommandFlags.High
      command.Run(leadImage)
      codecs.Save(leadImage, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Result.jpg", RasterImageFormat.Jpeg, 24)

      RasterCodecs.Shutdown()
   End Sub
C#Copy Code
ImageProcessing.SpecialEffects.SampleTargetCommand 
      public void SampleTargetCommandExample() 
      { 
         // Load an image 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
         codecs.ThrowExceptionsOnInvalidImages = true; 
 
         RasterImage image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Master.jpg"); 
 
         // Prepare the command 
         SampleTargetCommand command = new SampleTargetCommand(); 
         command.SampleColor = new RasterColor(50, 100, 150); 
         command.TargetColor = new RasterColor(60, 90, 150); 
         command.Flags       = SampleTargetCommandFlags.Red | SampleTargetCommandFlags.High; 
         command.Run(image); 
         codecs.Save(image, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Result.jpg", RasterImageFormat.Jpeg, 24); 
 
         RasterCodecs.Shutdown(); 
      }

Remarks

  • For example, suppose you are working with a color image. In the SampleColor property or the sampleColor parameter, set the red value portion of the RasterColor structure to 125, the green portion to 165 and the blue portion to 100. In the TargetColor property or the targetColor parameter you set the red value portion to 170, the green to 120 and the blue to 200. If you set SampleTargetCommandFlags.Blue in the Flags property or the flags parameter, then for every pixel in the image that has a blue value of 100, that blue value will be changed to 200, thus shifting the colors in the image. Depending on whether you set SampleTargetCommandFlags.Low, SampleTargetCommandFlags.Mid, or SampleTargetCommandFlags.High, either the shadow values in the blue channel will be remapped, or the midtone values in the blue channel will be remapped, or the highlight values in the blue channel will be remapped.
  • This command supports 12 and 16-bit grayscale and 48 and 64-bit color images.
  • For gray scale images the gray value of the SampleColor and TargetColor properties or the sampleColor and targetColor parameters are used, and the different channel flags have the same effect since it works on the same channel (gray channel). 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 signed data images.
  • This command does not support 32-bit grayscale images.
For more information, refer to Processing an Image.
For more information, refer to Correcting Colors.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Color.SampleTargetCommand

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also