ImageGear for C and C++ on Linux v19.10 - Updated
Display Grayscale Images
User Guide > How to Work with... > Formats with Additional Functionality > DICOM > Display Grayscale Images

Many medical images use more than 8 bits per grayscale pixel. The main concern in displaying such images is that commonly used monitors can display only 256 shades of gray, which corresponds to 8 bits per pixel. The 16-bit pixels need to be mapped in some way to 8-bit pixels. ImageGear uses two approaches for this mapping:

DICOM image files may contain several Look-Up Tables that describe how the image shall be displayed. "Modality" LUT specifies transform of image pixels into modality meaningful values, such as optical density or Hounsfield Units. "Value of Interest" LUT (VOI LUT) specifies what range of pixel intensities should be shown on the screen. Most often, both these LUTs are linear, and thus are presented by a pair of values that are similar to brightness and contrast. For Modality LUT, these are Rescale Intercept (0028, 1053) and Rescale Slope (0028, 1053). For VOI LUT, these are Window Center (0028, 1050) and Window Width (0028, 1051). The standard also allows the usage of non-linear LUTs. These LUTs are represented as an array of values that map source image intensities to the output range.

If all of these values are found in the file, they are all used to build the 16x8 LUT. If Rescale values are not found, default values (Intercept = 0.0, Slope=1.0) are substituted. If VOI LUT values are not found, the image is scanned for min and max pixel intensities, and the LUT is built to display the min intensity as black and max intensity as white. The values between min and max are linearly scaled between black and white.

You can adjust the values in the 16x8 LUT using MED_display_...() functions.

Grayscale LUTs can be attached to a HIGEAR or to a Display Group. In the latter case, if you are using multiple Display Groups corresponding to the same HIGEAR, they can have different LUTs, allowing you to display the same image with different contrast settings simultaneously, in different windows. See the "Medical Component Grayscale Look-Up Tables" section below for more details.

Grayscale LUTs (16x8, 8x8) only work with grayscale images. They do not work with bi-tonal, indexed (paletted), or color images.

This topic provides information about the following:

Pixel Padding Value

DICOM images sometimes contain a Data Element called "Pixel Padding Value" (PPV). The PPV is used mostly to fill in the corners of round images. DICOM provides a Tag for PPV which is (0028,0120). This Data Element stores a 16-bit grayscale value that is to be treated as the Pixel Padding Value. Any pixels in the image that have this value are not to be treated as meaningful objects - but as background color.

When the ImageGear Medical loads a DICOM image that contains a PPV, the value is captured and stored in the HDS, which is attached to the new image. In fact, 3 values are stored to the HDS: the PPV from the PPV Data Element, a flag indicating that a PPV was found in the file when it was loaded, and an 8-bit grayscale value used to display pixels with this value.

Use MED_DCM_DS_PixPadVal_get() and MED_DCM_DS_PixPadVal_set() functions to get/set the Pixel Padding Value that is to be used while displaying a 16-bit grayscale image.

Pseudocoloring Medical Images

Medical Display API contains methods for creating color LUTs that can be used to pseudocolor grayscale images.

MED_display_color_create() Chooses a pre-defined ImageGear pseudocolor scheme and creates 3 LUTs for the RGB components that are ready for use with display. You can call MED_display_color_set() to associate these RGB LUTs with an image.
MED_display_color_limits() Displays over- and under-saturated areas with the pseudocolor of your choice.
MED_display_color_set() Associates 3 LUTs with an image. Can be used to apply pseudocolor to an image. You can set to your own LUTs to the LUTs created by MED_display_color_create(), or set to NULL to use linear 0-255 grayscale LUTs.

Medical Component Grayscale Look-Up Tables

The ImageGear Medical component provides a set of functions that allows you to create grayscale look-up tables according to DICOM display attributes, such as VOI LUT, Modality LUT, Presentation LUT, etc.

Use the IG_LUT_create() function to create a grayscale LUT, then use MED_display_grayscale_LUT_build() function to fill this LUT with values corresponding to DICOM display settings. This function supports both linear and non-linear Modality and VOI LUTs, as well as presentation state related LUTs.

Once you have built the LUT, you can copy it to either the image, or to the image display settings, by using IG_image_grayscale_LUT_update_from() or IG_dspl_grayscale_LUT_update_from().

IG_image_grayscale_LUT_... API internally uses the same LUT as the one that can be set by IG_display_option_get/IG_display_option_set functions.

When ImageGear loads a grayscale DICOM image, it builds a grayscale LUT and attaches it to the image. This LUT can be obtained with the IG_image_grayscale_LUT_copy_get() function.

 C and C++
Copy Code
AT_MED_DCM_DISPLAY_SETTINGS DICOMDisplaySettings;
HIGLUT GrayLUT = (HIGLUT)NULL;
memset(&DICOMDisplaySettings, 0, sizeof(DICOMDisplaySettings));

if (MED_DCM_DS_LUT_exists(image, presentationState, DCM_TAG_ModalityLUTSequence))
{
    MED_DCM_DS_LUT_copy_get(image, presentationState, DCM_TAG_ModalityLUTSequence,
            &DICOMDisplaySettings.ModalityLUT);
}
else
{
    DICOMDisplaySettings.ModalityRescale.Slope = 1.0;
    DICOMDisplaySettings.ModalityRescale.Intercept = 0.0;
}

DICOMDisplaySettings.VOIWindow.Center = 1024;
DICOMDisplaySettings.VOIWindow.Width = 2048;
DICOMDisplaySettings.Gamma = 1.0;

AT_INT inputDepth = 12;
AT_BOOL inputIsSigned = FALSE:
// 8-bits is common for PC monitors.
AT_INT outputDepth = 8;
AT_BOOL outputIsSigned = FALSE:
IG_LUT_create(inputDepth, inputIsSigned, outputDepth, outputIsSigned, &GrayLUT);

// Build a grayscale LUT based on display settings
MED_display_grayscale_LUT_build(&DICOMDisplaySettings, GrayLUT);

// Copy LUT to the image. */
IG_image_grayscale_LUT_update_from(image, GrayLUT);
IG_LUT_destroy(GrayLUT);

See Also:

Grayscale Look-Up Tables