WindowLevelFillLUT method (Main Control)
Builder Syntax |
int WindowLevelFillLUT (Graphics::TColor clStart, Graphics::TColor clEnd, unsigned uLow, unsigned uHigh, unsigned uLowBit, unsigned uHighBit, unsigned uMinValue, unsigned uMaxValue, int nFactor, unsigned uFlags); |
Delphi Syntax |
Function WindowLevelFillLUT (clStart: TColor; clEnd: TColor; uLow: L_UINT; uHigh: L_UINT; uLowBit: L_UINT; uHighBit: L_UINT; uMinValue: L_UINT; uMaxValue: L_UINT; nFactor: L_INT; uFlags: L_UINT): L_INT; |
Overview |
Refer to Examining and Altering Bitmaps |
Remarks
(Document/Medical 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 the uFlags parameter is set to FILLLUT_LINEAR flag, 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 clStart to clEnd |
solid white (255,255,255) |
FILLLUT_OUTSIDE |
solid color (clStart) |
grayscale values from solid black (0,0,0) to solid white (255, 255, 255) |
solid color (clEnd) |
In either case, the grayscale values are a linear interpolation of uMinValue to uMaxValue 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 uLow and uHigh and stores the results in the lookup table, regardless of the value in uFlags parameter.
If uFlags parameter value is FILLLUT_EXPONENTIAL the value of nFactor parameter will modify 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 uLow parameter of this method
uEnd = the uHigh parameter of this method
If uFlags parameter value is FILLLUT_ LOGARITHMIC, the value of nFactor parameter will modify 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 uLow parameter of this method
uEnd = the uHigh parameter of this method
If uFlags parameter value is FILLLUT_ SIGMOID, the value of nFactor parameter will modify 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 uLow parameter of this method
uEnd = the uHigh parameter of this method
If uFlags parameter value is FILLLUT_LINEAR, the value of nFactor parameter will be ignored. The method fills the lookup table linearly.
Note: |
This method only works for 12- or 16-bit grayscale images. Using 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 uLow parameter to 1972, set uHigh parameter to 3273, and use FILLLUT_INSIDE option.
To map the values less than 1972 and greater than 3273, use FILLLUT_OUTSIDE option.
For more information on saving bitmaps that have been window leveled, refer to Saving Window-Leveled Bitmaps.
See Also
Elements: |
|
Topics: |
|
|
|
|
|
|
|
|