L_ApplyVOILUT

#include "l_bitmap.h"

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

pBITMAPHANDLE pBitmap;

/* pointer to the main bitmap handle */

L_UINT16 *pLUT;

/* pointer to the lookup table */

pDICOMLUTDESCRIPTOR pLUTDescriptor;

/* pointer to the structure describing the LUT parameters */

L_UINT uFlags;

/* flags */

Sets up the paint or paint and image processing functions' window leveling options for a specific bitmap through a lookup-table (LUT). This function is available in the Document/Medical Toolkit only.

Parameter

Description

pBitmap

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

pLUT

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

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])

uFlags

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 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).

Returns

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 only in the Document/Medical 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

LTIMGCOR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 2000 / XP/Vista.

See Also

Functions:

L_ApplyLinearVOILUT, L_RemapBitmapIntensity , L_ApplyModalityLUT , L_ApplyLinearModalityLUT, L_DicomGetVOILUT, L_DicomGetVOILUTData, L_AdjustBitmapTint, L_GammaCorrectBitmapExt

Topics:

Raster Image Functions: Modifying Intensity Values

 

Changing Brightness and Contrast

 

Raster Image Functions: Changing Brightness and Contrast

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;
}