←Select platform

WindowLevelExtCommand Constructor(Int32,Int32,RasterColor16[],RasterByteOrder)

Summary

Initializes a new WindowLevelExtCommand class object with explicit parameters.

Syntax

C#
VB
Java
Objective-C
C++
Public Function New( _ 
   ByVal lowBit As Integer, _ 
   ByVal highBit As Integer, _ 
   ByVal lookupTable() As Leadtools.RasterColor16, _ 
   ByVal order As Leadtools.RasterByteOrder _ 
) 
- (instancetype)initWithLookupTable:(NSArray<LTRasterColor16 *> *)lookupTable 
                             lowBit:(NSInteger)lowBit 
                            highBit:(NSInteger)highBit 
                              order:(LTRasterByteOrder)order 
public WindowLevelExtCommand( 
   int lowBit,  
   int highBit,  
   RasterColor16[] lookupTable,  
   RasterByteOrder order 
) 

Parameters

lowBit
Value indicating the low bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

highBit
Value indicating the high bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).

lookupTable
Optional 16-bit lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (HighBit - LowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains a 16-bit RGB quad. If lookupTable is null, the conversion is a normal shift (right or left) and the output image is 8-bit grayscale. If lookupTable is not null, the output image is a 24-bit image.

order
Value indicating the color order if the output image will be 48-bit. If LookupTable is null, this parameter is ignored.

Example

Run the WindowLevelExtCommand on an image.

C#
VB
Silverlight C#
Silverlight VB
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Core 
 
    
Public Sub WindowLevelExtConstructorExample() 
   Dim codecs As New RasterCodecs() 
   codecs.ThrowExceptionsOnInvalidImages = True 
   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")) 
 
   ' Prepare the command 
   'Change the image to 16-bit grayscale 
   Dim graycommand As GrayscaleCommand = New GrayscaleCommand(16) 
   graycommand.Run(leadImage) 
 
   Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand 
   MinMaxBits.Run(leadImage) 
 
   Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand 
   MinMaxValues.Run(leadImage) 
 
   Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)) 
   Dim LookupTable() As RasterColor16 
   ReDim LookupTable(Size - 1) 
   ' fill the first half of the LookupTable with RED. 
   Dim x As Long 
   For x = 0 To (Size \ 2 - 1) 
      LookupTable(CInt(x)) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) 
   Next 
   ' fill the rest with gray values. 
   For x = Size \ 2 To Size - 1 
      Dim y As Long = CType((x) * RasterColor16.MaximumComponent / (Size), Integer) 
      LookupTable(CInt(x)) = New RasterColor16(CInt(y), CInt(y), CInt(y)) 
   Next 
 
   Dim command As WindowLevelExtCommand = New WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr) 
   command.Run(leadImage) 
 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
 
       
public void WindowLevelExtConstructorExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE3.dcm")); 
 
   // Prepare the command 
   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); 
   MinMaxBits.Run(image); 
 
   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); 
   MinMaxValues.Run(image); 
 
   int Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); 
   RasterColor16 [] LookupTable = new RasterColor16[Size]; 
 
   // fill the first half of the LookupTable with RED. 
   for(int x = 0; x < Size / 2; x++) 
      LookupTable[x] = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); 
 
   // fill the rest with gray values. 
   for(int x = Size / 2; x < Size; x++) 
   { 
      int y = (UInt16)((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); 
      LookupTable[x] = new RasterColor16(y, y, y); 
   } 
 
   WindowLevelExtCommand command = new WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); 
 
   command.Run(image); 
 
} 
 
static class LEAD_VARS 
{ 
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
using Leadtools; 
using Leadtools.Examples; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
 
public void WindowLevelExtConstructorExample(RasterImage image, Stream outStream) 
{ 
   // Prepare the command 
   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand(); 
   MinMaxBits.Run(image); 
   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand(); 
   MinMaxValues.Run(image); 
 
   int Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)); 
   RasterColor16[] LookupTable = new RasterColor16[Size]; 
 
   // fill the first half of the LookupTable with RED. 
   for (int x = 0; x < Size / 2; x++) 
      LookupTable[x] = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); 
 
   // fill the rest with gray values. 
   for (int x = Size / 2; x < Size; x++) 
   { 
      int y = (UInt16)((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)); 
      LookupTable[x] = new RasterColor16(y, y, y); 
   } 
 
   WindowLevelExtCommand command = new WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr); 
 
   command.Run(image); 
   // Save result image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); 
   image.Dispose(); 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.Core 
 
Public Sub WindowLevelExtConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream) 
   ' Prepare the command 
   Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand() 
   MinMaxBits.Run(image) 
   Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand() 
   MinMaxValues.Run(image) 
 
   Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1)) 
   Dim LookupTable As RasterColor16() = New RasterColor16(Size - 1){} 
 
   ' fill the first half of the LookupTable with RED. 
   Dim x As Integer = 0 
   Do While x < Size / 2 
      LookupTable(x) = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) 
      x += 1 
   Loop 
 
   ' fill the rest with gray values. 
   x = Size / 2 
   Do While x < Size 
      Dim y As Integer = CUShort((x - MinMaxValues.MinimumValue) * RasterColor16.MaximumComponent / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue)) 
      LookupTable(x) = New RasterColor16(y, y, y) 
      x += 1 
   Loop 
 
   Dim command As WindowLevelExtCommand = New WindowLevelExtCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr) 
 
   command.Run(image) 
   ' Save result image 
   Dim codecs As RasterCodecs = New RasterCodecs() 
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24) 
   image.Dispose() 
End Sub 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.ImageProcessing.Core Assembly
Click or drag to resize