Leadtools Namespace > RasterPalette Class : WindowLevelFillLookupTableExt Method |
Value indicating the low bit used for leveling.
This is normally 0 and should be less than the 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.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.
public static void WindowLevelFillLookupTableExt( RasterColor16[] lookupTable, RasterColor16 startColor, RasterColor16 endColor, int low, int high, int lowBit, int highBit, int minValue, int maxValue, int factor, RasterPaletteWindowLevelFlags flags )
'Declaration Public Shared Sub WindowLevelFillLookupTableExt( _ ByVal lookupTable() As RasterColor16, _ ByVal startColor As RasterColor16, _ ByVal endColor As RasterColor16, _ 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 _ )
'Usage Dim lookupTable() As RasterColor16 Dim startColor As RasterColor16 Dim endColor As RasterColor16 Dim low As Integer Dim high As Integer Dim lowBit As Integer Dim highBit As Integer Dim minValue As Integer Dim maxValue As Integer Dim factor As Integer Dim flags As RasterPaletteWindowLevelFlags RasterPalette.WindowLevelFillLookupTableExt(lookupTable, startColor, endColor, low, high, lowBit, highBit, minValue, maxValue, factor, flags)
public static void WindowLevelFillLookupTableExt( RasterColor16[] lookupTable, RasterColor16 startColor, RasterColor16 endColor, int low, int high, int lowBit, int highBit, int minValue, int maxValue, int factor, RasterPaletteWindowLevelFlags flags )
+(BOOL)windowLevelFillLookupTableExt:(NSArray*)lookupTable startColor:(LTRasterColor16*)startColor endColor:(LTRasterColor16*)endColor low:(int)low high:(int)high lowBit:(unsigned int)lowBit highBit:(unsigned int)highBit minValue:(int)minValue maxValue:(int)maxValue factor:(int)factor flags:(LTRasterPaletteWindowLevelFlags)flags error:(NSError**)outError;
function Leadtools.RasterPalette.WindowLevelFillLookupTableExt( lookupTable , startColor , endColor , low , high , lowBit , highBit , minValue , maxValue , factor , flags )
public: static void WindowLevelFillLookupTableExt( array<RasterColor16>^ lookupTable, RasterColor16 startColor, RasterColor16 endColor, int low, int high, int lowBit, int highBit, int minValue, int maxValue, int factor, RasterPaletteWindowLevelFlags flags )
Value indicating the low bit used for leveling.
This is normally 0 and should be less than the 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.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.
This method is available in the Medical Toolkits.
Use this method to fill in the lookup table, used in RasterImage.WindowLevelExtCommand, 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) |
To fill an 8-bit lookup table use WindowLevelFillLookupTable.
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 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 more information, refer to Introduction to Image Processing With LEADTOOLS.
For more information, refer to Grayscale Images.
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Public Sub WindowLevelFillLookupTableExampleExt() Dim codecs As RasterCodecs = New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim 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 16-bit grayscale Dim image As RasterImage = codecs.Load(srcFileName, 16, CodecsLoadByteOrder.Gray, 1, 1) ' get the lookup table size Dim lookupTableSize As Integer = 1 << (image.HighBit - image.LowBit + 1) ' get low/hight bits and minimum/maximum value of this grayscale image Dim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand() minMaxBitsCmd.Run(image) Dim lowBit As Integer = minMaxBitsCmd.MinimumBit Dim highBit As Integer = minMaxBitsCmd.MaximumBit Dim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand() minMaxValuesCmd.Run(image) Dim minVal As Integer = minMaxValuesCmd.MinimumValue Dim maxVal As Integer = minMaxValuesCmd.MaximumValue ' create the lookup table Dim lookupTable As RasterColor16() = New RasterColor16(lookupTableSize - 1) {} Dim flags As RasterPaletteWindowLevelFlags = RasterPaletteWindowLevelFlags.Inside Or RasterPaletteWindowLevelFlags.Linear If image.Signed Then flags = flags Or RasterPaletteWindowLevelFlags.Signed End If ' initialize the fill lookup table parameters Dim startColor As RasterColor16 = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) ' Red Dim endColor As RasterColor16 = New RasterColor16(0, 0, RasterColor16.MaximumComponent) ' Blue Dim low As Integer = 23000 Dim high As Integer = 45000 Dim factor As Integer = 10 ' fill the lookup table RasterPalette.WindowLevelFillLookupTableExt(lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags) ' now do window level on the image image.WindowLevelExt(lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing) ' save it back on disk codecs.Save(image, destFileName, RasterImageFormat.Tif, 16) ' Clean up image.Dispose() 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 WindowLevelFillLookupTableExtExample() { 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 16 bit grayscale RasterImage image = codecs.Load(srcFileName, 16, CodecsLoadByteOrder.Gray, 1, 1); // get the lookup table size int lookupTableSize = 1 << (image.HighBit - image.LowBit + 1); // get low/hight bits and minimum/maximum value of this grayscale image MinMaxBitsCommand 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 table RasterColor16[] lookupTable = new RasterColor16[lookupTableSize]; RasterPaletteWindowLevelFlags flags = RasterPaletteWindowLevelFlags.Inside | RasterPaletteWindowLevelFlags.Linear; if(image.Signed) flags |= RasterPaletteWindowLevelFlags.Signed; // initialize the fill lookup table parameters RasterColor16 startColor = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); // red RasterColor16 endColor = new RasterColor16(0, 0, RasterColor16.MaximumComponent); // blue int low = 23000; int high = 45000; int factor = 10; // fill the lookup table RasterPalette.WindowLevelFillLookupTableExt( lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags); // now do window level on the image image.WindowLevelExt( lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing); // save it back on disk codecs.Save(image, destFileName, RasterImageFormat.Tif, 16); // Clean up image.Dispose(); }
using Leadtools; using Leadtools.Codecs; using Leadtools.Examples; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; using Leadtools.Windows.Media; public void WindowLevelFillLookupTableExtExample(RasterImage image, Stream destStream) { // image should be 16 bit grayscale RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; // get the lookup table size int lookupTableSize = 1 << (image.HighBit - image.LowBit + 1); // get low/hight bits and minimum/maximum value of this grayscale image MinMaxBitsCommand 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 table RasterColor16[] lookupTable = new RasterColor16[lookupTableSize]; RasterPaletteWindowLevelFlags flags = RasterPaletteWindowLevelFlags.Inside | RasterPaletteWindowLevelFlags.Linear; if(image.Signed) flags |= RasterPaletteWindowLevelFlags.Signed; // initialize the fill lookup table parameters RasterColor16 startColor = new RasterColor16(RasterColor16.MaximumComponent, 0, 0); // red RasterColor16 endColor = new RasterColor16(0, 0, RasterColor16.MaximumComponent); // blue int low = 23000; int high = 45000; int factor = 10; // fill the lookup table RasterPalette.WindowLevelFillLookupTableExt( lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags); // now do window level on the image image.WindowLevelExt( lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing); // save it back on disk codecs.Save(image, destStream, RasterImageFormat.Tif, 16); // Clean up image.Dispose(); }
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Core Imports Leadtools.Windows.Media Public Sub WindowLevelFillLookupTableExtExample(ByVal image As RasterImage, ByVal destStream As Stream) ' image should be 16 bit grayscale Dim codecs As RasterCodecs = New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True ' get the lookup table size Dim lookupTableSize As Integer = 1 << (image.HighBit - image.LowBit + 1) ' get low/hight bits and minimum/maximum value of this grayscale image Dim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand() minMaxBitsCmd.Run(image) Dim lowBit As Integer = minMaxBitsCmd.MinimumBit Dim highBit As Integer= minMaxBitsCmd.MaximumBit Dim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand() minMaxValuesCmd.Run(image) Dim minVal As Integer = minMaxValuesCmd.MinimumValue Dim maxVal As Integer = minMaxValuesCmd.MaximumValue ' create the lookup table Dim lookupTable As RasterColor16() = New RasterColor16(lookupTableSize - 1){} Dim flags As RasterPaletteWindowLevelFlags = RasterPaletteWindowLevelFlags.Inside Or RasterPaletteWindowLevelFlags.Linear If image.Signed Then flags = flags Or RasterPaletteWindowLevelFlags.Signed End If ' initialize the fill lookup table parameters Dim startColor As RasterColor16 = New RasterColor16(RasterColor16.MaximumComponent, 0, 0) ' red Dim endColor As RasterColor16 = New RasterColor16(0, 0, RasterColor16.MaximumComponent) ' blue Dim low As Integer = 23000 Dim high As Integer = 45000 Dim factor As Integer = 10 ' fill the lookup table RasterPalette.WindowLevelFillLookupTableExt(lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags) ' now do window level on the image image.WindowLevelExt(lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing) ' save it back on disk codecs.Save(image, destStream, RasterImageFormat.Tif, 16) ' Clean up image.Dispose() End Sub