ApplyModalityLUT method (Main Control)

C++ Builder example

Delphi example

 

Builder Syntax

int ApplyModalityLUT(L_PUINT16 pLUT, unsigned uNumberOfEntries, int nFirstStoredPixelValueMapped, unsigned uEntryBits, unsigned uFlags);

Delphi Syntax

Function ApplyModalityLUT (pLUT: L_PUINT16; uNumberOfEntries: L_UINT; nFirstStoredPixelValueMapped: L_INT; uEntryBits: L_UINT; uFlags: L_UINT): L_INT;

Overview

Refer to Changing Brightness and Contrast.

Remarks

(Medical only) Remaps the bitmap pixels through a lookup-table (LUT). In the DICOM world, this is referred to as "applying a non-linear Modality LUT".

This method is similar to RemapIntensity because it remaps the bitmap pixel values through a LUT. The method differs from RemapIntensity as follows:

image\sqrblit.gif ApplyModalityLUT allows you to specify an incomplete LUT. Values less than the first mapped index will be mapped to the first entry in the palette. Values higher than "first mapped index" + "LUT length" will be mapped to the last entry in the LUT.

image\sqrblit.gif ApplyModalityLUT only works on grayscale bitmaps. Calling this method for non-grayscale bitmaps will return an error (ERROR_INV_PARAMETER).

image\sqrblit.gif ApplyModalityLUT can create signed bitmaps. The output bitmap will be signed, if M_LUT_SIGNED is set, or unsigned, if M_LUT_SIGNED is not set.

The values in the LUT will be masked such that only the useful bits in the bitmap are considered. The values are considered as if the bitmap pixel values are normalized, LowBit = 0.

For example, if the bitmap is:

BitsPerPixel = 12

LowBit = 4

HighBit = 10

In this case, there are 10-4+1=7 valid bits. This means that there are 128 values to remap. For every pixel, ApplyModalityLUT will do the following:

Take the pixel value, shift it to the right by 4 and mask out the high bits, producing a value (val = 0..127).

val is remapped according to the LUT (values smaller than nFirstStoredPixelValueMapped are mapped to first LUT entry, while values greater than nFirstStoredPixelValueMapped + uNumberOfEntries are mapped to the last LUT entry)

After remapping, val is shifted to the left by 4 and will replace bits 4 thru 10 from the original bitmap

If the bitmap is signed, the indices for the LUT are assumed to be signed and be between –32768 and +32767.

If the bitmap is unsigned, the indices are unsigned and are between 0..65535.

It is recommended to always set the M_LUT_UPDATE_MIN_MAX flag.

This method is helpful in applying what is referred to as a "Non-Linear Modality LUT" in the DICOM world. According to the DICOM standard a "Modality LUT" defines the transformation of manufacturer-dependent pixel values into pixel values, which are manufacturer independent (e.g. Hounsfield units for CT, Optical Density for film digitizers, etc.).

This method supports 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is available only in the Document/Medical toolkits.

This method supports signed data images.

See Also

Elements:

RemapIntensity method, ApplyLinearModalityLUT method, ApplyVOILUT method, ApplyLinearVOILUT method.

Topics:

Raster Images: Modifying Intensity Values