WindowLevelFillLUT method (ILEADRaster)

Visual Basic example

Visual C++ 5.0 example

Delphi 4 example

C++ Builder example

 

Syntax

short WindowLevelFillLUT (OLE_COLOR crStart, OLE_COLOR crEnd, long nLow, long nHigh, short nLowBit, short nHighBit, long nMinValue, long nMaxValue, short nFactor, long lFlags);

Remarks

(Document/Medical Imaging only) Maps grayscale intensities to a specified color range, and fills the LevelLUT property with these values.

Use this method to fill the LevelLUT property, used in WindowLevel method, according to LUT type flag.

If you select FILLLUT_LINEAR the LevelLUT property will be filled as follows:

 

Inside/Outside

nMinValue-nLow

nLow-nHigh

nHigh-nMaxValue

FILLLUT_INSIDE

solid black (0,0,0)

color gradient ranging from crStart to crEnd

solid white (255,255,255)

FILLLUT_OUTSIDE

solid color (crStart)

grayscale values from solid black (0,0,0) to solid white (255, 255, 255)

solid color (crEnd)

 

In either case, the grayscale values are a linear interpolation of nMinValue to nMaxValue into RGB(0,0,0) to RGB(255,255,255).

The nFactor parameter is used for log, exp and sigmoid functions only. If nFactor = 0 the method performs a linear interpolation between the two points nLow and nHigh and stores the results in the lookup table, regardless of the value in lFlags.

If lFlag is FILLLUT_EXPONENTIAL the value of nFactor modifies the lookup table values (see figure below) according to the following equations:

 

Y

=

uStart

+

(uEnd – uStart) * (exp ((nFactor/10. * (x-uStart))/(uEnd-uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where :

 

nFirstValue = exp(0).

nLastValue = exp(nFactor)

x = the intensity value of the selected point

uStart = the nLow parameter of this method

uEnd = the nHigh parameter of this method

 

image\WinLevel2.gif

If lFlag is FILLLUT_ LOGARITHMIC the value of nFactor modifies the lookup table values (see figure below) according to the following equations:

 

Y

=

uStart

+

(uEnd – uStart) * (ln (1 + (nFactor/10. * (x-uStart))/(uEnd- uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where:

 

nFirstValue = 0.

nLastValue = ln(1 + nFactor)

x = the intensity value of the selected point

uStart = the nLow parameter of this method

uEnd = the nHigh parameter of this method

 

image\WinLevel1.gif

If lFlag is FILLLUT_ SIGMOID the value of nFactor modifies the lookup table values (see figure below)according to the following equations:

 

Y

=

uStart

+

(uEnd – uStart) * (1./ (1 + exp(2*nFactor/10. * (x-Center))/(uEnd- uStart)) - nFirstValue)

 

 

 

 

(nLastValue – nFirstValue)

where:

 

nFirstValue = 1./(1+exp(2.*nFactor/10.*(nStart - Center)/ (uEnd- uStart))).

nLastValue = 1./(1+exp(2.*nFactor/10.*(nEnd - Center)/ (uEnd- uStart))).

Center = (nEnd + nStart)/2.

x = the intensity value of the selected point

uStart = the nLow parameter of this method

uEnd = the nHigh parameter of this method

image\WinLevel3.gif

If lFlag is FILLLUT_LINEAR, nFactor is ignored. The method fills the lookup table linearly.

Note: This method only works for 12 or 16 bit grayscale images. Trying to use this method with other images will result in an error.

You must allocate the memory for the LUT before calling this method. You can calculate the required size with (sizeof(RGBQUAD) * (1<<(pBitmap->HighBit - pBitmap->LowBit + 1))), as seen in the example below.

For example, suppose you are working with a 12 bit grayscale image. There are 4096 intensity levels in a 12 bit image (2 raised to the 12th power). Normally, the interval between 0 and 4095 would be mapped to colors between (0, 0, 0) and (255, 255, 255). With this method, any value that falls between the low level and the high level will be mapped to colors between the start color and the end color. If you do not want a mapping function, set the start and end colors equal.

If you only want to map the values between 1972 and 3273 (in a 12-bit image), then set nLow to 1972, set nHigh to 3273, and set bInside to TRUE. To map the values less than 1972 and greater than 3273, select FILLLUT_OUTSIDE option.

For information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.

See Also

Elements

WindowLevel method, LevelLUT property

Topics:

Using Color Values in LEADTOOLS

 

Saving Window-Leveled Bitmaps