Fills the user-allocated 8-bit LUT with values ranging between the startColor and endColor colors according to the selected LUT type using DICOM style.
public static void WindowLevelFillLookupTable2(RasterColor[] lookupTable,RasterColor startColor,RasterColor endColor,int low,int high,int lowBit,int highBit,int minValue,int maxValue,int factor,RasterPaletteWindowLevelFlags flags)
Public Shared Sub WindowLevelFillLookupTable2( _ByVal lookupTable() As RasterColor, _ByVal startColor As RasterColor, _ByVal endColor As RasterColor, _ByVal low As Integer, _ByVal high As Integer, _ByVal lowBit As Integer, _ByVal highBit As Integer, _ByVal minValue As Integer, _ByVal maxValue As Integer, _ByVal factor As Integer, _ByVal flags As RasterPaletteWindowLevelFlags _)
+(BOOL)windowLevelFillLookupTable2:(NSArray*)lookupTablestartColor:(LTRasterColor*)startColorendColor:(LTRasterColor*)endColorlow:(int)lowhigh:(int)highlowBit:(unsigned int)lowBithighBit:(unsigned int)highBitminValue:(int)minValuemaxValue:(int)maxValuefactor:(int)factorflags:(LTRasterPaletteWindowLevelFlags)flagserror:(NSError**)outError;
public:static void WindowLevelFillLookupTable2(array<RasterColor>^ lookupTable,RasterColor startColor,RasterColor endColor,int low,int high,int lowBit,int highBit,int minValue,int maxValue,int factor,RasterPaletteWindowLevelFlags flags)
lookupTable
Pointer to an array to be updated with the 8-bit RGB quad (i.e. lookup table).
startColor
Starting color value for the gradient.
endColor
Ending color value for the gradient.
low
The low value of the window width, in pixels. This value is shifted internally by LowBit value.
high
The high value for the window width, in pixels. This value is shifted internally by LowBit value.
lowBit
Value indicating the low bit used for leveling.
This is normally 0 and should be less than the highBit.
highBit
Value indicating the high bit used for leveling.
This should be greater than or equal to lowBit and less than 11 for 12-bit grayscale or 15 for 16-bit grayscale.
minValue
The image minimum value. This value can be obtained using MinMaxValuesCommand.
maxValue
The image maximum value. This value can be obtained using MinMaxValuesCommand.
factor
Value that indicates the factor to be applied in the method operation specified in the flags parameter.
This parameter is used only if flags is RasterPaletteWindowLevelFlags.Exponential, RasterPaletteWindowLevelFlags.Logarithmic or RasterPaletteWindowLevelFlags.Sigmoid.
If RasterPaletteWindowLevelFlags.Exponential or RasterPaletteWindowLevelFlags.Sigmoid is specified, its value can be any integer (+/-). If RasterPaletteWindowLevelFlags.Logarithmic is specified, its value should be >>= 0. If factor = 0, the lookup table will be filled linearly.
flags
Flags that indicate how the range is used to fill and the type of the lookup table and whether it contains signed or unsigned data.
This method is available in the Medical Toolkits.
Use this method to fill in the lookup table, used in RasterImage.WindowLevel, according to the lookup table type flag.
The lookup table will be filled as follows:
| Inside/Outside | MinValue-Low | Low-High | High-MaxValue | |
|---|---|---|---|---|
| RasterPaletteWindowLevelFlags.Inside | solid black (0,0,0) | color gradient ranging from startColor to endColor | solid white (255,255,255) | |
| RasterPaletteWindowLevelFlags.Outside | solid color ( startColor) | grayscale values from solid black (0,0,0) to solid white (255, 255, 255) | solid color ( endColor) | |
| RasterPaletteWindowLevelFlags.Inside | RasterPaletteWindowLevelFlags.DicomStyle | None | color gradient ranging from startColor to endColor | None |
| RasterPaletteWindowLevelFlags.Outside | RasterPaletteWindowLevelFlags.DicomStyle | solid color ( startColor) | color gradient ranging from startColor to endColor | solid color ( endColor) |
This method assumes DICOM style always.
To fill a 16-bit lookup table use WindowLevelFillLookupTableExt.
Only TIFF and DICOM file formats are capable of saving images that have been window-leveled.
Images can be window-leveled by calling RasterImage.WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter, by using the WindowLevelCommand 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.
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.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using LeadtoolsExamples.Common;public void WindowLevelFillLookupTable2Example(){RasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;string srcFileName = Path.Combine(ImagesPath.Path, "Image1.cmp");string destFileName = Path.Combine(ImagesPath.Path, "Image1_WindowLevel.tif");// Load an image as 8 bits/pixelRasterImage image = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1);// change the image to be 16-bit grayscaleGrayscaleCommand grayscaleCmd = new GrayscaleCommand(16);grayscaleCmd.Run(image);// get the lookup table sizeint lookupTableSize = 1 << (image.HighBit - image.LowBit + 1);// get low/hight bits and minimum/maximum value of this grayscale imageMinMaxBitsCommand minMaxBitsCmd = new MinMaxBitsCommand();minMaxBitsCmd.Run(image);int lowBit = minMaxBitsCmd.MinimumBit;int highBit = minMaxBitsCmd.MaximumBit;MinMaxValuesCommand minMaxValuesCmd = new MinMaxValuesCommand();minMaxValuesCmd.Run(image);int minVal = minMaxValuesCmd.MinimumValue;int maxVal = minMaxValuesCmd.MaximumValue;// create the lookup tableRasterColor[] lookupTable = new RasterColor[lookupTableSize];RasterPaletteWindowLevelFlags flags =RasterPaletteWindowLevelFlags.Inside |RasterPaletteWindowLevelFlags.Linear;if (image.Signed)flags |= RasterPaletteWindowLevelFlags.Signed;// initialize the fill lookup table parametersRasterColor startColor = RasterColor.FromKnownColor(RasterKnownColor.Red);RasterColor endColor = RasterColor.FromKnownColor(RasterKnownColor.Blue);int low = 23000;int high = 45000;int factor = 10;// fill the lookup tableRasterPalette.WindowLevelFillLookupTable2(lookupTable,startColor,endColor,low,high,lowBit,highBit,minVal,maxVal,factor,flags);// now do window level on the imageimage.WindowLevel(lowBit,highBit,lookupTable,RasterWindowLevelMode.PaintAndProcessing);// save it back on diskcodecs.Save(image, destFileName, RasterImageFormat.Tif, 16);// Clean upimage.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CorePublic Sub WindowLevelFillLookupTable2Example()Dim codecs As RasterCodecs = New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = TrueDim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_WindowLevel.tif")' Load an image as 8 bits/pixelDim image As RasterImage = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1)' change the image to be 16-bit grayscaleDim grayscaleCmd As GrayscaleCommand = New GrayscaleCommand(16)grayscaleCmd.Run(image)' get the lookup table sizeDim lookupTableSize As Integer = 1 << (image.HighBit - image.LowBit + 1)' get low/hight bits and minimum/maximum value of this grayscale imageDim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand()minMaxBitsCmd.Run(image)Dim lowBit As Integer = minMaxBitsCmd.MinimumBitDim highBit As Integer = minMaxBitsCmd.MaximumBitDim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand()minMaxValuesCmd.Run(image)Dim minVal As Integer = minMaxValuesCmd.MinimumValueDim maxVal As Integer = minMaxValuesCmd.MaximumValue' create the lookup tableDim lookupTable As RasterColor() = New RasterColor(lookupTableSize - 1) {}Dim flags As RasterPaletteWindowLevelFlags = RasterPaletteWindowLevelFlags.Inside Or RasterPaletteWindowLevelFlags.LinearIf image.Signed Thenflags = flags Or RasterPaletteWindowLevelFlags.SignedEnd If' initialize the fill lookup table parametersDim startColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Red)Dim endColor As RasterColor = RasterColor.FromKnownColor(RasterKnownColor.Blue)Dim low As Integer = 23000Dim high As Integer = 45000Dim factor As Integer = 10' fill the lookup tableRasterPalette.WindowLevelFillLookupTable2(lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags)' now do window level on the imageimage.WindowLevel(lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing)' save it back on diskcodecs.Save(image, destFileName, RasterImageFormat.Tif, 16)' Clean upimage.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
c#[Silverlight C# Example]using Leadtools;using Leadtools.Codecs;using Leadtools.Examples;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.Windows.Media;public void WindowLevelFillLookupTable2Example(RasterImage image, Stream destStream){// image should be 8 bits/pixelRasterCodecs codecs = new RasterCodecs();codecs.ThrowExceptionsOnInvalidImages = true;// change the image to be 16-bit grayscaleGrayscaleCommand grayscaleCmd = new GrayscaleCommand(16);grayscaleCmd.Run(image);// get the lookup table sizeint lookupTableSize = 1 << (image.HighBit - image.LowBit + 1);// get low/hight bits and minimum/maximum value of this grayscale imageMinMaxBitsCommand minMaxBitsCmd = new MinMaxBitsCommand();minMaxBitsCmd.Run(image);int lowBit = minMaxBitsCmd.MinimumBit;int highBit = minMaxBitsCmd.MaximumBit;MinMaxValuesCommand minMaxValuesCmd = new MinMaxValuesCommand();minMaxValuesCmd.Run(image);int minVal = minMaxValuesCmd.MinimumValue;int maxVal = minMaxValuesCmd.MaximumValue;// create the lookup tableRasterColor[] lookupTable = new RasterColor[lookupTableSize];RasterPaletteWindowLevelFlags flags =RasterPaletteWindowLevelFlags.Inside |RasterPaletteWindowLevelFlags.Linear;if (image.Signed)flags |= RasterPaletteWindowLevelFlags.Signed;// initialize the fill lookup table parametersRasterColor startColor = RasterColorConverter.FromColor(Colors.Red);RasterColor endColor = RasterColorConverter.FromColor(Colors.Blue);int low = 23000;int high = 45000;int factor = 10;// fill the lookup tableRasterPalette.WindowLevelFillLookupTable2(lookupTable,startColor,endColor,low,high,lowBit,highBit,minVal,maxVal,factor,flags);// now do window level on the imageimage.WindowLevel(lowBit,highBit,lookupTable,RasterWindowLevelMode.PaintAndProcessing);// save it back on diskcodecs.Save(image, destStream, RasterImageFormat.Tif, 16);// Clean upimage.Dispose();}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.Windows.MediaPublic Sub WindowLevelFillLookupTable2Example(ByVal image As RasterImage, ByVal destStream As Stream)' image should be 8 bits/pixelDim codecs As RasterCodecs = New RasterCodecs()codecs.ThrowExceptionsOnInvalidImages = True' change the image to be 16-bit grayscaleDim grayscaleCmd As GrayscaleCommand = New GrayscaleCommand(16)grayscaleCmd.Run(image)' get the lookup table sizeDim lookupTableSize As Integer = 1 << (image.HighBit - image.LowBit + 1)' get low/hight bits and minimum/maximum value of this grayscale imageDim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand()minMaxBitsCmd.Run(image)Dim lowBit As Integer = minMaxBitsCmd.MinimumBitDim highBit As Integer = minMaxBitsCmd.MaximumBitDim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand()minMaxValuesCmd.Run(image)Dim minVal As Integer = minMaxValuesCmd.MinimumValueDim maxVal As Integer = minMaxValuesCmd.MaximumValue' create the lookup tableDim lookupTable As RasterColor() = New RasterColor(lookupTableSize - 1) {}Dim flags As RasterPaletteWindowLevelFlags = RasterPaletteWindowLevelFlags.Inside Or RasterPaletteWindowLevelFlags.LinearIf image.Signed Thenflags = flags Or RasterPaletteWindowLevelFlags.SignedEnd If' initialize the fill lookup table parametersDim startColor As RasterColor = RasterColorConverter.FromColor(Colors.Red)Dim endColor As RasterColor = RasterColorConverter.FromColor(Colors.Blue)Dim low As Integer = 23000Dim high As Integer = 45000Dim factor As Integer = 10' fill the lookup tableRasterPalette.WindowLevelFillLookupTable2(lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags)' now do window level on the imageimage.WindowLevel(lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing)' save it back on diskcodecs.Save(image, destStream, RasterImageFormat.Tif, 16)' Clean upimage.Dispose()End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
