L_LTIMGCOR_API L_INT L_ApplyVOILUT (pBitmap, pLUT, pLUTDescriptor, uFlags)
Sets up the paint or paint and image processing functions' window leveling options for a specific bitmap through a lookup-table (LUT).
Pointer to the bitmap handle referencing the bitmap to be leveled.
Pointer to the LUT which contains the lookup table. The length of the LUT is in
Pointer to a structure describing the LUT. The following structure members are used:
|nFirstStoredPixelValueMapped||Indicates the first index whose remapped value is stored in the LUT. All bitmap display LUT entries which are less than this value will be remapped to pLUT.|
|uNumberOfEntries||The number of entries in
Flags which determine the behavior of this function. Possible values are one or an OR-ed combination of the following:
|VOI_LUT_UPDATE_MIN_MAX||[0x0001] If set, the function will recalculate
|VOI_LUT_REVERSE_ORDER||[0x0002] If set, the function will fill the bitmap display LUT in reverse order (light to dark instead of dark to light).|
|VOI_LUT_PAINT_ONLY||[0x0004] Set the LUT for paint only, not image processing. For more information, refer to BITMAPHANDLE.Flags.UseLUT.|
|VOI_LUT_IGNORE_EXISTING_PALETTE||[0x0008] If set, the function will exclude any existing LookupTable or palette from the calculations.|
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
This function sets up the paint or paint and image processing functions' window leveling options for a specific bitmap through a lookup-table (LUT). In the DICOM world, this is referred to as "applying a non-linear VOI LUT".
This function will remap the LUT used to display and process a bitmap by applying a user-defined lookup table. In the DICOM world this is referred to as applying a "non-linear VOI LUT". The DICOM standard states:
"A VOI LUT defines the transformation of the modality pixel values into pixel values that are meaningful for print, display, etc. This transformation is applied after any Modality LUT". Please see "VOI LUT Module Attributes" in the DICOM standard for more details.
This function does not change the image data; it only updates the entries inside the bitmap display LUT.
It is recommended to always set the VOI_LUT_UPDATE_MIN_MAX flag.
In the DICOM world you will need to set VOI_LUT_REVERSE_ORDER flag if the photometric interpretation of the image is "MONOCHROME1", where the minimum grayscale value is intended to be displayed as white after any VOI gray scale transformations have been performed.
This function supports 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is available in the Document and Medical Imaging toolkits.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Required DLLs and Libraries
Win32, x64, Linux.
L_INT ApplyVOILUTExample(pBITMAPHANDLE pBitmap, L_BOOL bLinear)
// Apply "Abdomen T1" window-level , high bit is assumed
// to be "11" and low bit "0.
nRet = L_ApplyLinearVOILUT (pBitmap, 330.0, 600.0, 0);
L_UINT16 * pLUT;
// allocate and initialize the LUT
pLUT = (L_UINT16 *)malloc(0x1000 * sizeof(L_UINT16));
for(i = 0; i < 0x1000; i++)
if(i < 30)
pLUT[i] = 0;
if(i > 630)
pLUT[i] = 630;
pLUT[i] = i ;
// fill the LUTDescriptor structure
LUTDescriptor.uStructSize = sizeof(LUTDescriptor);
LUTDescriptor.nFirstStoredPixelValueMapped = 0;
LUTDescriptor.uEntryBits = 16;
LUTDescriptor.uNumberOfEntries = 0x1000;
// apply the LUT
nRet = L_ApplyVOILUT(pBitmap, pLUT, &LUTDescriptor, 0);
if(nRet != SUCCESS)
// free the LUT
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries