Sets up the paint or paint & image processing functions' window leveling options for a specific bitmap through a lookup-table (LUT).


#include "ltwrappr.h"

virtual L_INT LBitmap::ApplyVOILUT(pLUT, pLUTDescriptor, uFlags)



Pointer to the LUT which contains the lookup table. The length of the LUT is in pLUTDescriptor->uNumberOfEntries


Pointer to a structure describing the LUT. The following structure members are used:

Value Meaning
nFirstStoredPixelValueMapped 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[0].
uNumberOfEntries The number of entries in pLUT all bitmap display LUT entries which are greater than nFirstStoredPixelValueMapped + uNumberOfEntries will be set to the last entry in the LUT (pLUT[uNumberOfEntries 1])

L_UINT uFlags

Flags which determine the behavior of this function. Use one value or use a bitwise OR ( | ) to combine values. Possible values are:

Value Meaning
VOI_LUT_UPDATE_MIN_MAX [0x0001] Recalculate pBitmap->MinVal based on the minimum intensity inside the bitmap and recalculate pBitmap->MaxVal based on the maximum intensity inside the bitmap.
VOI_LUT_REVERSE_ORDER [0x0002] 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.


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


This function sets up the paint or paint & 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 only in the Document/Medical toolkits.

This function supports signed data images.

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.

See Also




L_INT LBitmap__ApplyVOILUTExample(LBitmap *plBitmap, L_BOOL bLinear)  
  L_INT    nRet;  
     // Apply "Abdomen T1" window-level , high bit is assumed  
     // to be "11" and low bit "0.  
    nRet =plBitmap->ApplyLinearVOILUT( 330.0, 600.0, 0); 
    if(nRet !=SUCCESS) 
       return nRet; 
     L_UINT16 *      pLUT;  
     L_INT                i;  
     // allocate and initialize the LUT 
     pLUT = (L_UINT16 *)malloc(0x1000 * sizeof(L_UINT16));  
        return ERROR_NO_MEMORY;  
     for(i = 0; i <= 0x1000; i++) 
        if(i < 30)  
           pLUT[i] = 0;  
           if(i > 630)  
              pLUT[i] = 630;             
              pLUT[i] =(L_UINT16) i ;             
     // fill the LUTDescriptor structure 
     LUTDescriptor.uStructSize = sizeof(DICOMLUTDESCRIPTOR); 
     LUTDescriptor.nFirstStoredPixelValueMapped = 0;  
     LUTDescriptor.uEntryBits = 16;  
     LUTDescriptor.uNumberOfEntries = 0x1000;  
     // apply the LUT    
     nRet =plBitmap->ApplyVOILUT(pLUT, &LUTDescriptor, 0); 
     if(nRet !=SUCCESS) 
        return nRet; 
     // free the LUT 
   return SUCCESS; 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help