Grayscale Images
LEADTOOLS provides a number of method for working with grayscale images. Many of these method 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 GrayScale method. The GrayScaleExt method 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 ConvertToColoredGray method 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 ColorizeGray method.
(Medical only) The ShiftData method 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 SelectData method 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.
The BitmapAlpha property lets you get or set the alpha channel information of an image.
The GrayScaleToDuotone method converts a grayscale bitmap into a colored one by mixing or replacing the original values of the pixels with new colors.
The GrayScaleToMultitone method 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 Desaturate method converts the image to a grayscale level by reducing the saturation of each color to zero. The conversion will not change the color resolution.
When working with grayscale images, a LookUp Table (LUT) may be used to remap pixel values. The UseLUT property determines when the LUT is used. If the UseLUT property is TRUE, then the LUT is used in all image processing methods and when saving an image. If the UseLUT property is FALSE, the LUT is used only when painting the image. The UseLUT property is used primarily with 12 and 16-bit grayscale images, and may be used in association with window leveling. For more information on window leveling, refer to the "Window Leveling" section given below.
Changing the Highlight pen and Cursor Style (Document/Medical only)
When working with grayscale images containing many midrange grays, the user may find that both the highlight pen and the cursor are difficult to see properly. In such cases, the user should set the AnnAutoHilightPen property and the AnnAutoCursor property. These two functions let the user set 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.
Getting information about grayscale images
LEADTOOLS also provides method for getting information about grayscale images. The GetMinMaxBits method provides information on the minimum and maximum bit set in a 12 or 16 - bit grayscale image. The GetMinMaxVal method 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 determine the kind of grayscale palette associated with a bitmap, if any, check the IsGrayScale property.
Window leveling (Document/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. The bit range is specified by LevelLowBit property and LevelHighBit property. The user defined color map is defined by LevelLUT property. LevelLowBit property, LevelHighBit property and LevelLUT property will only affect the way the image is painted and will not affect the image data. To affect the image data, you must call the WindowLevel method. The WindowLevelBitmap property determines whether the WindowLevel method creates a new 8 or 24-bit bitmap, or leaves the bitmap as a 12 or 16-bit grayscale. The WindowLevel method applies window leveling to the bitmap, and resets LevelLowBit property, LevelHighBit property, LevelLUTLength property and LevelLUT property if a new 8 or 24-bit bitmap is created. LevelLowBit property and LevelHighBit property indicate which bits are considered image data. LevelLUT is a remapping palette that provides the colors to use when remapping the image. MinBit property, MaxBit property, MinVal property and MaxVal property can aid in setting up the LevelLUT by providing information concerning the bitmap. These values are retrieved using GetMinMaxBits method and GetMinMaxVal method. You can set the values for the MinBit and MaxBit of the bitmap data using the SetMinMaxBits method. For more information, refer to the individual entries for the properties and methods. Window leveling applied with the WindowLevel method can be saved to TIF or DICOM formats without changing the bitmap data. For more information, refer to Saving Window-Leveled Bitmaps.