WindowLevelFillLookupTable Method (original) (raw)

Summary

Fills the user-allocated 8-bit LUT with values ranging between the startColor and endColor colors according to the selected LUT type.

Syntax

C#

Objective-C

C++/CLI

Python

public static void WindowLevelFillLookupTable( [RasterColor](rastercolor.html)[] _lookupTable_, [RasterColor](rastercolor.html) _startColor_, [RasterColor](rastercolor.html) _endColor_, int _low_, int _high_, int _lowBit_, int _highBit_, int _minValue_, int _maxValue_, int _factor_, [RasterPaletteWindowLevelFlags](rasterpalettewindowlevelflags.html) _flags_ )

+(BOOL)windowLevelFillLookupTable:(NSArray*)_lookupTable_ startColor:(LTRasterColor*)_startColor_ endColor:(LTRasterColor*)_endColor_ low:(int)_low_ high:(int)_high_ lowBit:(unsigned int)_low_Bit highBit:(unsigned int)_high_Bit minValue:(int)_minValue_ maxValue:(int)_maxValue_ factor:(int)_factor_ flags:(LTRasterPaletteWindowLevelFlags)_flags_ error:(NSError**)outError;

public: static void WindowLevelFillLookupTable( [array<RasterColor>^](rastercolor.html) _lookupTable_, [RasterColor](rastercolor.html) _startColor_, [RasterColor](rastercolor.html) _endColor_, int _low_, int _high_, int _lowBit_, int _highBit_, int _minValue_, int _maxValue_, int _factor_, [RasterPaletteWindowLevelFlags](rasterpalettewindowlevelflags.html) _flags_ )

def WindowLevelFillLookupTable(self,] lookupTable,startColor,endColor,low,high,lowBit,highBit,minValue,maxValue,factor,flags): 

Parameters

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.

high
The high value for the window width, in pixels.

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.

Example

using Leadtools; using Leadtools.Codecs; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Core; public void WindowLevelFillLookupTableExample() { RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_WindowLevel.tif"); // Load an image as 8 bits/pixel RasterImage image = codecs.Load(srcFileName, 8, CodecsLoadByteOrder.Rgb, 1, 1); // change the image to be 16-bit grayscale GrayscaleCommand grayscaleCmd = new GrayscaleCommand(16); grayscaleCmd.Run(image); // 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 RasterColor[] lookupTable = new RasterColor[lookupTableSize]; RasterPaletteWindowLevelFlags flags = RasterPaletteWindowLevelFlags.Inside | RasterPaletteWindowLevelFlags.Linear; if (image.Signed) flags |= RasterPaletteWindowLevelFlags.Signed; // initialize the fill lookup table parameters RasterColor startColor = RasterColor.FromKnownColor(RasterKnownColor.Red); RasterColor endColor = RasterColor.FromKnownColor(RasterKnownColor.Blue); int low = 23000; int high = 45000; int factor = 10; // fill the lookup table RasterPalette.WindowLevelFillLookupTable( lookupTable, startColor, endColor, low, high, lowBit, highBit, minVal, maxVal, factor, flags); // now do window level on the image image.WindowLevel( lowBit, highBit, lookupTable, RasterWindowLevelMode.PaintAndProcessing); // save it back on disk codecs.Save(image, destFileName, RasterImageFormat.Tif, 16); // Clean up image.Dispose(); } static class LEAD_VARS { public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; }