Lookup Table (LUT) in BITMAPHANDLE and its use for Displaying Images and Performing Image Processing

Certain members in the BITMAPHANDLE structure mentioned below are intended for internal use, including pLUT/pLUT16, PaintHighBit and PaintLowBit. These members are used when window-leveling. More information can be found in the LTKRN.H header file, which describes the entire structure.

Lookup Table (LUT)

12-/16-bit bitmaps can use a lookup table (LUT) for displaying images or performing image processing. However, using LUT is optional (it can be NULL). If the LUT is not NULL, it can be used for 'displaying' or for 'displaying and performing image processing'. The LUT data is created by window-leveling (L_ApplyLinearVOILUTL_WindowLevel) or by loading a DICOM or TIFF file with window-leveling information.

There are 3 cases:

  1. 'No LUT'
  2. 'LUT exists and is used for display only'
  3. 'LUT exists and is used for display and image processing'

BITMAPHANDLE Fields

The LUT data is stored in the BITMAPHANDLE using the following fields:

pLUT

Pointer to an array of L_RGBQUAD values containing the corresponding color for each LUT entry. Usually, the L_RGBQUAD entries contain grayscale colors. But sometimes, the L_RGBQUAD entries contain non-grayscale colors. The number of entries is determined by Flags.UseLUT, LowBit, HighBit, PaintLowBit and PaintHighBit entries in the BITMAPHANDLE structure. If pLUT is NULL and pLUT16 is NULL, then there is no LUT (case '1' above).

pLUT16

Just like pLUT, except that the array contains L_RGBQUAD16 values and each color value is 16-bit. 16-bit values provide extra precision compared to 8-bit values.

Flags.UseLUT

If TRUE, the LUT data is used for displaying and performing image processing (case '3' above). In this case, the number of LUT entries is determined by LowBit and HighBit:

LUT Length = 1 << (HighBit – LowBit + 1) 

If FALSE, the LUT is used only for display. In this case, the number of LUT entries is determined by PaintLowBit and PaintHighBit:

LUT Length = 1 << (PaintHighBit – PaintLowBit + 1) 

pLUT and pLUT16 are synchronized (that is, they contain the same information). If pLUT == NULL and pLUT16 != NULL, then there is a LUT. Conversely, if pLUT != NULL and pLUT16 == NULL, there is a LUT.

If pLUT != NULL and pLUT16 != NULL, there is a LUT and both arrays will point to the same colors and have the same length.

PaintLowBit/PaintHighBit can be different from LowBit/HighBit, but usually they are the same.

Here are the 3 cases again:

  1. 'No LUT': pLUT == NULL
  2. 'LUT used for display only':pLUT != NULL and Flags.UseLUT == FALSE (or 0)
  3. 'LUT used for display and image processing': pLUT != NULL and Flags.UseLUT == TRUE (or 1)

In cases '1' and '2', image processing will be performed on image data.

In case '3', image processing is performed and there is a LUT. The image can look completely different after image processing, so it is best to regenerate the LUT data to make sure you see all the details in the new bitmap. Regenerate the LUT by doing something like this:

L_GetMinMaxVal(pBitmap, MinVal, MaxVal); 
L_ApplyLinearVOILUT(pBitmap, (MinVal + MaxVal / 2), (MaxVal – MinVal) / 2, 0); 

In case '3', the image processing would typically take the LUT colors into account.

Using Various Image Processing Function Types

There are several types of image processing functions and the output will vary, producing one of these results:

Image Processing Modes

In some instances image processing performs well when using LUT, while in other cases it is better if the LUT is ignored. You can choose whichever mode is more appropriate for your application. Here is how you can get to each mode:

  1. 'No LUT': L_WindowLevel(pBitmap, pBitmap->LowBit, pBitmap->HighBit, NULL, 0, WINDOWLEVEL_PAINT)
  2. 'LUT used for display only': L_WindowLevel(pBitmap, lowbit, highbit, pLUT, LUTLength, WINDOWLEVEL_PAINT)
  3. 'LUT used for display and image processing': L_WindowLevel(…, WINDOWLEVEL_PAINT_AND_PROCESSING) or L_ApplyLinearVOILUT.

You can also switch between '2' and '3' by switching the pBitmap->Flags.UseLUT flag between 0 and 1. But when doing so, make sure PaintLowBit == LowBit and PaintHighBit == HighBit. The above L_WindowLevel calls can also be replaced with L_WindowLevelExt function calls in order to use 16-bit entries for the LUT.

References

L_ApplyLinearVOILUT

L_WindowLevel

L_WindowLevelExt

BITMAPHANDLE

Help Version 20.0.2019.3.12
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help