L_ApplyLinearModalityLUT

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_ApplyLinearModalityLUT (pBitmap, fIntercept, fSlope, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the main bitmap handle */

L_DOUBLE fIntercept;

/* rescale intercept */

L_DOUBLE fSlope;

/* rescale slope */

L_UINT uFlags;

/* flags */

Remaps the bitmap pixels by applying a linear transformation described by a rescale slope and an intercept. This function is available in the Medical Toolkit only.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap that will be changed.

fIntercept

"Rescale Intercept" : the value of "b" in the linear relationship between original pixel values and the new pixel values.

 

(new pixel value) = m * (original pixel value) + b. Where "m" is the "Rescale Slope".

fSlope

"Rescale Slope" : the value of "m" in the linear relationship between original pixel values and the new pixel values.

 

(new pixel value) = m * (original pixel value) + b. Where "b" is the "Rescale Intercept".

uFlags

Flags which determine the behavior of this function. Possible values are:

 

Value

Meaning

 

M_LUT_UPDATE_MIN_MAX

[0x0002] If set, the function will update pBitmap->MinVal with the new minimum intensity value in the bitmap and pBitmap->MaxVal with the new maximum intensity value.

 

M_LUT_ALLOW_RANGE_EXPANSION

[0x0008] If set, the function will adjust the high bit and/or low bit (if possible) inside the bitmap handle in order to be able to hold the range of pixel values after applying the modality LUT.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function remaps the bitmap pixels by applying a linear transformation described by rescale slope and intercept. In the DICOM world, this is referred to as "applying a linear Modality LUT".

This function will remap the bitmap pixels by applying the linear transformation described by the equation:

Y = mX + b

m: slope of a straight line, this is also referred to as "Rescale Slope" in the DICOM world.

b: the y-intercept of a straight line, this is also referred to as "Rescale Intercept" in the DICOM world.

Y: the resulting pixel value.

X: the input or original pixel value.

 

This function is helpful in applying what is referred to as a "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 function only works on grayscale bitmaps. Calling this function for non-grayscale bitmaps will return an error (ERROR_INV_PARAMETER).

It is recommended to always set the M_LUT_UPDATE_MIN_MAX flag.

This function could change the bitmap from signed to unsigned, or from unsigned to signed. This is determined by the values of the resulting image pixels after applying the linear transformation.

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, let’s say 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.

This function supports signed data images.

If M_LUT_ALLOW_RANGE_EXPANSION is set in uFlags, consider the following example:

If the dataset has the following attributes:

Bits per pixel

16

High Bit

11

Low Bit

0

Pixel Range

0 to +4095,

Unsigned

 

The number of bits stored inside the bitmap is 11-0+1 =12.

If the fIntercept is set to –1024 and fSlope is set to 0, then after applying the rescale slope and intercept:

Output minimum pixel value = (0 *1 +(-1024))= -1024

Output maximum pixel value = (4095 *1 +(-1024))= 3071

The new pixel value range (–1024 to 3071) can’t be represented with the current bits stored (12 bits), which can represent values in the range (–2048 to 2048). In this case the function will change the high bit inside the bitmap handle to be 12 instead of 11 (bits stored becomes 13), which can represent values in the range (–8192 to 8191).

Please note that the function won’t be able to update the high bit and/or low bit if the number of bits stored was already equal to the bitmap bits per pixel.

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.

Required DLLs and Libraries

LTIMG

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 95 / 98 / Me, Windows 2000 / XP.

See Also

Functions:

L_RemapBitmapIntensity, L_ApplyLinearModalityLUT, L_ApplyVOILUT, L_ApplyLinearVOILUT, L_DicomGetModalityLUTAttributes, L_AdjustBitmapTint, L_GammaCorrectBitmapExt

Topics:

Raster Image Functions: Modifying Intensity Values

 

Changing Brightness and Contrast

 

Raster Image Functions: Changing Brightness and Contrast

Example

For an example, refer to L_ApplyModalityLUT.