Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Grayscale Images

LEADTOOLS for .NET provides a number of classes/methods for working with grayscale images. Many of these classes/methods work on either grayscale images or color images. Some of the LEADTOOLS classes/methods 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 GrayscaleCommand class. The GrayScaleExtendedCommand class 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.

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

The GrayScaleToDuotoneCommand class converts a grayscale image into a colored one by mixing or replacing the original values of the pixels with new colors.

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

The CreateAlphaImage method creates a grayscale image from the alpha channel information of an image.

The DesaturateCommand class 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 ShiftDataCommand class selects a specified number of bits from an 8, 12 or 16-bit grayscale image into a mask and places the mask in a new 8, 12 or 16-bit grayscale image. The SelectDataCommand class selects a specified number of bits of an 8, 12 or 16-bit grayscale image and puts them into a mask, then colors the image depending on the mask. This can show image variances depending on user-defined conditions.

Getting information about grayscale images

LEADTOOLS also provides functions for getting information about grayscale images. The MinMaxBitsCommand class provides information on the minimum and maximum bit set in a 12 or 16 - bit grayscale image. The MinMaxValuesCommand class 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/Medical toolkits. To get a full histogram of a 12 or 16-bit grayscale image, use HistogramCommand.

To determine the kind of grayscale palette associated with an image, if any, use GrayscaleMode.

Window-leveling (Medical only)

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 classes/methods are provided for window-leveling. WindowLevel provides "on demand" window-leveling for the paint functions and does not alter the image, and WindowLevelCommand converts the image to a window leveled 8 or 24 bit RGB image. The bit range is passed to the methods through LowBit and HighBit and the user-defined color map is passed through LookupTable . To help set up a bit range and a color map, use MinMaxBitsCommand and MinMaxValuesCommand. MinMaxBitsCommand gets the minimum and maximum bits of the values present in a 12 or 16-bit grayscale image. MinMaxValuesCommand gets the minimum and maximum intensity values of the image. WindowLevelFillLookupTable fills the user-allocated LookupTable (LUT) with a color gradient based on the specified values.

Window-leveling applied with the WindowLevelCommand class can be saved to TIF or DICOM formats without changing the image data. For more information, refer to Saving Window-Leveled Images.

Color Halftone and Halftone Images

LEADTOOLS provides a number of commands for working with color images and changing them so they are suitable for printing using halftoning techniques. For more information about these commands, refer to Color Halftone and Halftone Images.