Sets up the paint or paint and image processing methods' window leveling options for this RasterImage
public void WindowLevelExt(int lowBit,int highBit,RasterColor16[] palette,RasterWindowLevelMode mode)
Public Sub WindowLevelExt( _ByVal lowBit As Integer, _ByVal highBit As Integer, _ByVal palette() As RasterColor16, _ByVal mode As RasterWindowLevelMode _)
- (BOOL)windowLevelExt:(NSInteger)lowBitValuehighBit:(NSInteger)highBitValuepalette:(nullable NSArray<LTRasterColor16 *> *)palettemode:(LTRasterWindowLevelMode)modeerror:(NSError **)error
public void windowLevelExt(int lowBit,int highBit,RasterColor16[] palette,RasterWindowLevelMode mode)
public:void WindowLevelExt(int lowBit,int highBit,array<RasterColor16>^ palette,RasterWindowLevelMode mode)
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).
palette
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 color. If palette is null, the conversion is a normal shift (right or left) and the painted image is 8 or 16-bit grayscale. If palette is not null, the painted image is a 48-bit image.
mode
Value indicating whether palette is used by the paint and image processing methods or only by the paint methods.
This method is available in the (Document/Medical only) Toolkits.
Provides "on demand" window leveling for the paint methods and does not alter the image data. To convert the image data to a window leveled image, use WindowLevelExt.
If RasterWindowLevelMode.PaintAndProcessing is specified, then all image processing methods will take the palette into account.
Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by calling WindowLevelExt and specifying RasterWindowLevelMode.PaintAndProcessing for the mode parameter, by using the WindowLevelExt 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 a version of this function that uses an 8-bit palette, see WindowLevel.
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 Leadtools.ImageProcessing.Color;using Leadtools.Dicom;using Leadtools.Drawing;using Leadtools.Controls;using LeadtoolsExamples.Common;using Leadtools.Svg;public void WindowLevelExtExample(){RasterCodecs codecs = new RasterCodecs();// Load a 16-bit grayscale imageRasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "IMAGE2.DCM"));// Get the min and max valuesMinMaxBitsCommand minMaxBitsCmd = new MinMaxBitsCommand();minMaxBitsCmd.Run(image);MinMaxValuesCommand minMaxValuesCmd = new MinMaxValuesCommand();minMaxValuesCmd.Run(image);int lowBit = minMaxBitsCmd.MinimumBit;int highBit = minMaxBitsCmd.MaximumBit;int size = (1 << (image.HighBit - image.LowBit + 1));RasterColor16[] palette = new RasterColor16[size];// fill the first half of the LUT with REDfor (int x = 0; x < size / 2; x++){palette[x].R = RasterColor16.MaximumComponent;palette[x].G = 0;palette[x].B = 0;palette[x].Reserved = 0;}int minVal = minMaxValuesCmd.MinimumValue;int maxVal = minMaxValuesCmd.MaximumValue;// Fill the rest with gray valuesfor (int x = (size / 2); x < size; x++){palette[x].R = Convert.ToUInt16(Math.Min(RasterColor16.MaximumComponent, (Convert.ToUInt32(x - minVal) * RasterColor16.MaximumComponent) / (maxVal - minVal)));palette[x].G = palette[x].R;palette[x].B = palette[x].R;palette[x].Reserved = 0;}image.WindowLevelExt(lowBit, highBit, palette, RasterWindowLevelMode.PaintAndProcessing);codecs.Save(image, Path.Combine(ImagesPath.Path, "IMAGE1_WindowLevel.BMP"), RasterImageFormat.Bmp, 0);image.Dispose();codecs.Dispose();}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.ControlsImports Leadtools.DicomImports Leadtools.DrawingImports Leadtools.SvgPublic Sub WindowLevelExtExample()Dim codecs As RasterCodecs = New RasterCodecs()' Load a 16-bit grayscale imageDim image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE2.DCM"))' Get the min and max valuesDim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand()minMaxBitsCmd.Run(image)Dim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand()minMaxValuesCmd.Run(image)Dim lowBit As Integer = minMaxBitsCmd.MinimumBitDim highBit As Integer = minMaxBitsCmd.MaximumBitDim size As Integer = (1 << (image.HighBit - image.LowBit + 1))Dim palette As RasterColor16() = New RasterColor16(size - 1) {}' fill the first half of the LUT with REDDim x As Integer = 0Do While x < size / 2palette(x).R = RasterColor16.MaximumComponentpalette(x).G = 0palette(x).B = 0palette(x).Reserved = 0x += 1LoopDim minVal As Integer = minMaxValuesCmd.MinimumValueDim maxVal As Integer = minMaxValuesCmd.MaximumValue' Fill the rest with gray valuesx = (size \ 2)Do While x < sizepalette(x).R = Convert.ToUInt16(Math.Min(RasterColor16.MaximumComponent,(Convert.ToUInt32(x - minVal) * RasterColor16.MaximumComponent) / (maxVal - minVal)))palette(x).G = palette(x).Rpalette(x).B = palette(x).Rpalette(x).Reserved = 0x += 1Loopimage.WindowLevelExt(lowBit, highBit, palette, RasterWindowLevelMode.PaintAndProcessing)codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_WindowLevel.BMP"), RasterImageFormat.Bmp, 0)image.Dispose()codecs.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.Dicom;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Examples;using Leadtools.Windows.Media;public void WindowLevelExtExample(RasterImage image, Stream destStream){// Get the min and max valuesMinMaxBitsCommand minMaxBitsCmd = new MinMaxBitsCommand();minMaxBitsCmd.Run(image);MinMaxValuesCommand minMaxValuesCmd = new MinMaxValuesCommand();minMaxValuesCmd.Run(image);int lowBit = minMaxBitsCmd.MinimumBit;int highBit = minMaxBitsCmd.MaximumBit;int size = (1 << (image.HighBit - image.LowBit + 1));RasterColor16[] palette = new RasterColor16[size];// fill the first half of the LUT with REDfor (int x = 0; x < size / 2; x++){palette[x].R = RasterColor16.MaximumComponent;palette[x].G = 0;palette[x].B = 0;palette[x].Reserved = 0;}int minVal = minMaxValuesCmd.MinimumValue;int maxVal = minMaxValuesCmd.MaximumValue;// Fill the rest with gray valuesfor (int x = (size / 2); x < size; x++){palette[x].R = Convert.ToUInt16(Math.Min(RasterColor16.MaximumComponent, (Convert.ToUInt32(x - minVal) * RasterColor16.MaximumComponent) / (maxVal - minVal)));palette[x].G = palette[x].R;palette[x].B = palette[x].R;palette[x].Reserved = 0;}image.WindowLevelExt(lowBit, highBit, palette, RasterWindowLevelMode.PaintAndProcessing);RasterCodecs codecs = new RasterCodecs();codecs.Save(image, destStream, RasterImageFormat.Bmp, 0);image.Dispose();}vb[Silverlight VB Example]Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DicomImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.CoreImports Leadtools.ImageProcessing.ColorImports Leadtools.Windows.MediaPublic Sub WindowLevelExtExample(ByVal image As RasterImage, ByVal destStream As Stream)' Get the min and max valuesDim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand()minMaxBitsCmd.Run(image)Dim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand()minMaxValuesCmd.Run(image)Dim lowBit As Integer = minMaxBitsCmd.MinimumBitDim highBit As Integer = minMaxBitsCmd.MaximumBitDim size As Integer = (1 << (image.HighBit - image.LowBit + 1))Dim palette As RasterColor16() = New RasterColor16(size - 1) {}' fill the first half of the LUT with REDDim x As Integer = 0Do While x < size / 2palette(x).R = RasterColor16.MaximumComponentpalette(x).G = 0palette(x).B = 0palette(x).Reserved = 0x += 1LoopDim minVal As Integer = minMaxValuesCmd.MinimumValueDim maxVal As Integer = minMaxValuesCmd.MaximumValue' Fill the rest with gray valuesx = (size / 2)Do While x < sizepalette(x).R = Convert.ToUInt16(Math.Min(RasterColor16.MaximumComponent, (Convert.ToUInt32(x - minVal) * RasterColor16.MaximumComponent) / (maxVal - minVal)))palette(x).G = palette(x).Rpalette(x).B = palette(x).Rpalette(x).Reserved = 0x += 1Loopimage.WindowLevelExt(lowBit, highBit, palette, RasterWindowLevelMode.PaintAndProcessing)Dim codecs As RasterCodecs = New RasterCodecs()codecs.Save(image, destStream, RasterImageFormat.Bmp, 0)image.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
