Leadtools.ImageProcessing.Core Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
SelectDataCommand Class
See Also  Members   Example 
Leadtools.ImageProcessing.Core Namespace : SelectDataCommand Class



Selects a specific number of bits of an 8, 12 or 16-bit grayscale image and puts them into a mask, then colors the image depending on the mask. This can show image variances depending on user-defined conditions. This command is available in the Medical toolkits.

Syntax

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

Example

Run the SelectDataCommand on an image.

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

   Dim leadImage As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Beauty16.jpg")

   ' Prepare the command
   Dim command As SelectDataCommand = New SelectDataCommand
   command.Color = New RasterColor(233, 10, 77)
   command.Combine = True
   command.SourceLowBit = 2
   command.SourceHighBit = 6
   command.Threshold = 25

   command.Run(leadImage)
   codecs.Save(command.DestinationImage, LeadtoolsExamples.Common.ImagesPath.Path + "SelectDataResult.bmp", RasterImageFormat.Bmp, 24)

   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void SelectDataCommandExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Beauty16.jpg"); 
 
   // Prepare the command 
   SelectDataCommand command = new SelectDataCommand(); 
   command.Color = new RasterColor(233, 10, 77); 
   command.Combine = true; 
   command.SourceLowBit = 2; 
   command.SourceHighBit = 6; 
   command.Threshold = 25; 
 
   command.Run(image); 
   codecs.Save(command.DestinationImage, LeadtoolsExamples.Common.ImagesPath.Path + "SelectDataResult.Bmp", RasterImageFormat.Bmp, 24); 
 
   RasterCodecs.Shutdown(); 
}

Remarks

  • This command is used as a visualization aid. You can select certain bits of the supported type image and show the variances of that image under conditions that you define.
  • For 8, 12 and 16-bit grayscale image, the source low bit can range from 0 to 7, 11, and 15 respectively. However if this value exceeded the range then the method will not return an error, and the DestinationImage will be a pure black image.
  • For 8, 12 and 16-bit grayscale image, the source high bit can range from source low bit to 7, 11, and 15 respectively. No error will be returned if source high bit is greater than 7, 11 or 15. The command will return an invalid parameter error if source high bit < source low bit.
  • The command will first construct a mask from bits source low bit through source high bit. For each pixel, the pixel value will be combined with the mask using a bitwise 'and' operation. The result will be shifted to the right by source low bit. This result will be compared with the threshold: if the value is greater than or equal to the threshold, the output pixel's color is changed using the Color property or the color paramater if you ar using the appropriate Constructor. If the result is less than the threshold, the output is set to 0.
  • The following example shows you how to treat a 16-bit grayscale image:
    • In a 16-bit grayscale image, the bits are ordered as b15 b14 b13 ... b2 b1 b0.
    • For SourceLowBit = 3, SourceHighBit = 8, Threshold = 16 and Color = new RasterColor(0, 255, 0)
    • In Source image (SourceImage)
    • -------------------
    • b15 b14 b13 b12 b11 b10 b9 |b8 b7 b6 b5 b4 b3| b2 b1 b0
    • -------------------
    • 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1
  • In our case, the mask is 010011 in base 2 (19 in decimal). Since 19 >= 16, the destination pixel will be colored using the Color property (or the color parameter of the Constructor). The output pixel will be:
    • if Combine = false: Color = new RasterColor(0,255,0)
    • if Combine = true: we take the high byte of the source pixel, which is 01101110 in base 2 (0x6E), and then the value is AND-ed with each component of the color. So the output pixel will be RGB(0x00 & 0x6E, 0xFF & 0x6E, 0x00 & 0x6E) which is RGB(0x00, 0x6E, 0x00).
  • Let us consider another case: the source pixel is 0110111000011101 the mask value is 000011 in base 2(3 in decimal). Since 3 > 16, the destination pixel will be:
    • if the combine value = false: Color = new RasterColor(0,0,0)
    • if the combine value = true: The high byte of the source pixel will bet set for the RGB, that is RGB(0x6E, 0x6E, 0x6E).
  • This command supports 8, 12 and 16-bit grayscale bitmaps only. Support for 12 and 16-bit grayscale images are available only in the Document/Medical toolkits. It also can process the whole image or a region of the image. If an image has a region, the effect is applied only to the region.
  • This command does not support 32-bit grayscale images.
For more information, refer to Correcting Colors.
For more information, refer to Grayscale Images.

Inheritance Hierarchy

System.Object
   Leadtools.ImageProcessing.RasterCommand
      Leadtools.ImageProcessing.Core.SelectDataCommand

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