Grayscale Images

LEADTOOLS provides a number of functions for working with grayscale images. Many of these functions work on either grayscale images or color images. Some of the LEADTOOLS functions however, are designed specifically for use with grayscale images, either creating a grayscale image, getting information about a grayscale image, or window leveling.

Creating and working with grayscale images

A color image can be converted to a grayscale image using the L_GrayScaleBitmap and L_CreateGrayScaleBitmap functions. The L_GrayScaleBitmapExt function converts an image to a grayscale image, but provides the user the ability to control the calculation of the grayscale pixel value by giving the R, G and B components different "weights" when calculating the grayscale value.

L_CreateGrayScaleBitmap function converts an image to a grayscale image, but allows the user to control the LOW and HIGH bit of the result image.

LEADTOOLS also provides the L_ConvertToColoredGray function which converts a bitmap into a grayscale bitmap, while allowing the user to add color effects. This creates an image with an "old-fashioned" look. An 8, 12 or 16-bit grayscale can also be colorized using L_ColorizeGrayBitmap.

The L_GrayScaleToDuotone function converts a grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with new colors.

The L_GrayScaleToMultitone converts a grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with one or more new colors.

The L_GetBitmapAlpha function creates a grayscale image from the alpha channel information of an image.

The L_DesaturateBitmap function converts the image to a grayscale level by reducing the saturation of each color to zero. The conversion will not change the color resolution.

The L_OtsuThreshold performs image segmentation and color reduction using Otsu clustering on grayscale images.

Getting information about grayscale images

LEADTOOLS also provides functions for getting information about grayscale images. The L_GetMinMaxBits provides information on the minimum and maximum bit set in a 12 or 16 - bit grayscale image. The L_GetMinMaxVal function gets the minimum and maximum intensity values present in a 12 or 16-bit grayscale image. Please note that support for 12 and 16-bit grayscale images is only available in Document and Medical Imaging toolkits. To get a full histogram of a 12 or 16-bit grayscale image, call L_GetBitmapHistogram.

To determine the kind of grayscale palette associated with a bitmap, if any, call L_IsGrayScaleBitmap.

Document and Medical Imaging toolkits:

Changing the Highlight pen and Cursor Style

When working with grayscale images containing many midrange grays, it may be difficult to see the highlight pen and the cursor. In such cases, the user should call L_AnnSetAutoHilightPen and L_AnnSetAutoCursor. These two functions let the user set both the default highlight pen color, used in drawing and selecting, and the cursor, respectively. By changing the default highlight pen color and the cursor style, the user can greatly improve highlight and cursor visibility.

Window leveling

Window leveling is only valid for 12 and 16-bit grayscale images, and is used to map grayscale intensities by specifying the bit range and/or a user defined color map. Two functions are provided for window leveling. L_WindowLevel provides "on demand" window leveling for the paint functions and does not alter the image, and L_WindowLevelBitmap converts the image to a window leveled 8 or 24 bit RGB bitmap. The bit range is passed to the functions through nLowBit and nHighBit parameters and the user defined color map is passed through the pLUT parameter. To help set up a bit range and a color map, use L_GetMinMaxBits and L_GetMinMaxVal. L_GetMinMaxBits gets the minimum and maximum bits of the values present in a 12 or 16-bit grayscale image. L_GetMinMaxVal gets the minimum and maximum intensity values of the image. L_WindowLevelFillLUT fills the user-allocated LUT with a color gradient based on the specified values. For more information, refer to the individual entries for the functions. Window leveling applied with the L_WindowLevel function can be saved to TIF or DICOM formats without changing the bitmap data. For more information, refer to Saving Window-Leveled Bitmaps.

LEADTOOLS supports two types of LUTs for 10-16-bit grayscale images (8-bit LUT and 16-bit LUT). Typical grayscale image display and processing is done using an 8-bit LUT. But, you can also use a 16-bit LUT, which offers more precision. Some special video cards and monitors also support display of grayscale images using a 16-bit LUT.

For more information about using the members of the BITMAPHANDLE structure when window-leveling, refer to Lookup Table (LUT) in BITMAPHANDLE and its use for Displaying Images and Performing Image Processing.

Medical Imaging Toolkits:

The L_ShiftBitmapData function selects a specified number of bits from an 8, 12 or 16-bit grayscale bitmap into a mask and places the mask in a new 8, 12 or 16-bit grayscale bitmap. The L_SelectBitmapData function selects a specified number of bits of an 8, 12 or 16-bit grayscale bitmap and puts them into a mask, then colors the bitmap depending on the mask. This can show bitmap variances depending on user-defined conditions.

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

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.