L_ApplyVOILUT

Summary

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

Syntax

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_ApplyVOILUT (pBitmap, pLUT, pLUTDescriptor, uFlags)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap to be leveled.

L_UINT16 *pLUT

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

pDICOMLUTDESCRIPTOR pLUTDescriptor

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

Value Meaning
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[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. Possible values are one or an OR-ed combination of the following:

Value Meaning
VOI_LUT_UPDATE_MIN_MAX [0x0001] If set, the function will 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] 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.

Returns

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

Comments

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

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_INT ApplyVOILUTExample(pBITMAPHANDLE pBitmap, L_BOOL bLinear) 
{ 
   L_INT    nRet; 
 
   if (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); 
   } 
   else 
   { 
      L_UINT16* pLUT; 
      L_UINT16           i; 
      DICOMLUTDESCRIPTOR LUTDescriptor; 
 
      // allocate and initialize the LUT 
      pLUT = (L_UINT16*)malloc(0x1000 * sizeof(L_UINT16)); 
      if (!pLUT) 
         return ERROR_NO_MEMORY; 
 
      for (i = 0; i < 0x1000; i++) 
      { 
         if (i < 30) 
         { 
            pLUT[i] = 0; 
         } 
         else 
            if (i > 630) 
            { 
               pLUT[i] = 630; 
            } 
            else 
            { 
               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) 
      { 
         return nRet; 
      } 
 
      // free the LUT 
      free(pLUT); 
   } 
   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 API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.