←Select platform

WindowLevelExtCommand Class

Summary
Converts a 12 or 16-bit grayscale image to a 16-bit grayscale or a 48-bit RGB image. This class is available in Document/Medical toolkits only.
Syntax
C#
VB
Objective-C
C++
Java
public class WindowLevelExtCommand : RasterCommand 
Public Class WindowLevelExtCommand  
   Inherits RasterCommand 
@interface LTWindowLevelExtCommand : LTRasterCommand 
public class WindowLevelExtCommand extends RasterCommand 
public ref class WindowLevelExtCommand : public RasterCommand   
Remarks
  • This command supports 12 and 16-bit grayscale. Support for 12 and 16-bit grayscale images is available only in the Document/Medical toolkits.
  • This command does not support 32-bit grayscale images.
  • RasterByteOrder.Gray is not supported by this command.

Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling WindowLevelExtCommand and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter, by using the WindowLevelExtCommand or by loading an image from a file format that supports Window Leveling. If a window-leveled image is saved as any other file format, the image data will be converted before being saved. For more information, refer to Saving Window-Leveled Images. See WindowLevelCommand for a version of this class using 8-bit lookup tables. LEADTOOLS supports two types of LUTs for 10-16-bit grayscale images (8-bit LUT and 16-bit LUT). Typical grayscale image display and processing is done using an 8-bit LUT. But, you can also use a 16-bit LUT, which offers more precision. Some special video cards and monitors also support display of grayscale images using a 16-bit LUT. For more information, refer to Introduction to Image Processing With LEADTOOLS. For more information, refer to Grayscale Images.

Example

Run the WindowLevelExtCommand on an image.

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
 
public void WindowLevelExtCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")); 
 
   // Prepare the command 
   int x; 
   int y; 
   int Size; 
   RasterColor16[] LookupTable; 
 
   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); 
   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); 
   WindowLevelExtCommand command = new WindowLevelExtCommand(); 
 
   MinMaxBits.Run(image); 
   MinMaxValues.Run(image); 
 
   Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); 
   LookupTable = new Leadtools.RasterColor16[Size]; 
 
   // fill the first half of the LookupTable with RED. 
   for (x = 0; x < Size / 2; x++) 
      LookupTable[x] = new Leadtools.RasterColor16(Leadtools.RasterColor16.MaximumComponent, 0, 0); 
 
   // fill the rest with gray values. 
   for (x = Size / 2; x < Size; x++) 
   { 
      y = (int)((x - MinMaxValues.MinimumValue) * Leadtools.RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); 
      LookupTable[x] = new Leadtools.RasterColor16(y, y, y); 
   } 
 
   command.HighBit = MinMaxBits.MaximumBit; 
   command.LowBit = MinMaxBits.MinimumBit; 
   command.LookupTable = LookupTable; 
   command.Order = Leadtools.RasterByteOrder.Bgr; 
 
   command.Run(image); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Core 
 
Public Sub WindowLevelExtCommandExample() 
 
   'Load an image 
   Dim codecs As New RasterCodecs() 
   codecs.ThrowExceptionsOnInvalidImages = True 
 
   Dim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")) 
 
   ' Prepare the command 
   Dim x As Long 
   Dim y As Long 
   Dim Size As Long 
   Dim LookupTable() As RasterColor16 
 
   Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand() 
   Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand() 
   Dim Command As WindowLevelExtCommand = New WindowLevelExtCommand() 
 
   MinMaxBits.Run(image) 
   MinMaxValues.Run(image) 
 
   Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)) 
   LookupTable = New RasterColor16(CInt(Size)) {} 
 
   ' fill the first half of the LookupTable with RED. 
   For x = 0 To CInt(Size / 2) 
      LookupTable(CInt(x)) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) 
   Next 
 
   ' fill the rest with gray values. 
   For x = CInt(Size / 2) To Size 
      y = CLng(((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue))) 
      LookupTable(CInt(x)) = New RasterColor16(CInt(y), CInt(y), CInt(y)) 
   Next 
 
   Command.HighBit = MinMaxBits.MaximumBit 
   Command.LowBit = MinMaxBits.MinimumBit 
   Command.LookupTable = LookupTable 
   Command.Order = RasterByteOrder.Bgr 
 
   Command.Run(image) 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

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

Leadtools.ImageProcessing.Core Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.