Basic Brightness and Contrast Functions
With the basic brightness and contrast functions you can change the intensity or contrast using a flat scale, or you can adjust the gamma correction. Gamma correction changes brightness using a logarithmic scale to account for visual perception. You can apply the basic brightness and contrast functions either to the display or to a bitmap.
To adjust the display, use the following functions:
LBitmapBase::SetPaintIntensity
These functions affect the display of all bitmaps. They are not really part of the image processing group, because they do not affect the bitmap. Nevertheless, these functions can be more useful than the image processing functions when the need for brightness and contrast improvement is device-specific, rather than image-specific.
To change the brightness and contrast of a bitmap, use the LBitmap::ChangeIntensity, LBitmap::ChangeContrast, and LBitmap::GammaCorrect or LBitmap::GammaCorrectExt. If you use these functions, the changes become permanent when you save the bitmap in a file.
The LBitmap::Add function can be used to improve the brightness of an image by adding a list of bitmaps. The list of bitmaps consists of several "versions" of the same view or image.
The LBitmap::AdaptiveContrast function performs adaptive contrast enhancement (ACE) to areas that are originally low in contrast.
The LBitmap::ColorIntensityBalance function changes the distribution of the red, green, or blue channels.
The LBitmap::ContBrightInt function applies brightness, contrast and intensity adjustments to enhance the image tonal range.
The LBitmap::ChangeHueSatInt function can be used to change the hue, saturation and brightness of all or specified colors in the image. This function combines the functionality found in the LBitmap::ChangeHue, LBitmap::ChangeSaturation, and LBitmap::ChangeIntensity functions and allows you to change the overall hue, saturation and intensity all at one time, or adjust the parameters separately, or make adjustments in successive passes.
The LBitmap::MathFunction function can be used to adjust the hue, saturation and brightness of an image by applying one of five mathematical functions to a bitmaps pixel values: square, square root, log, sine, and cosine and then multiplying the results by specified factor.
The LBitmap::AddWeighted function can be used to improve the brightness of an image by adding bitmaps within a bitmap list. Typically, you would call this function for a series of images taken for the same object at short intervals. This function can also be used to obtain an image as the sum of several weighted images.
The LBitmap::IntensityDetect function filters the specified bitmap to detect colors in a specified intensity range in all planes or a specific plane.
The LBitmap::Multiply function can be used to increase or decrease the brightness in the bitmap by multiplying the colors in the specified bitmap by a value equal to the uFactor value divided by 100. For example, if uFactor is 131 the colors in the specified bitmap will be multiplied by 1.31.
Special Functions
The LBitmap::SubtractBackground is useful, especially with medical images and grayscale bitmaps, in correcting nonuniform brightness. This function uses a rolling ball algorithm to determine what points are background points. A small rolling ball radius identifies small objects and a larger radius identifies both large and small objects. Because frequently the resulting image is dim, this function includes the functionality similar to that of the LBitmap::Multiply in order to include the capability for increasing the brightness of the final image.
The LBitmap::DynamicBinary function converts a bitmap into a black and white image without changing its bits per pixel by using a local threshold value for each pixel of the image.
The LBitmap::MultiScaleEnhancement function wraps techniques of image enhancements, such as contrast enhancement, edge enhancement and latitude reduction, for Computed Radiography (CR).
Histogram-Based Contrast Functions
Some image processing functions use an internally generated histogram for more sophisticated contrast improvements. The histogram is a table that reflects how many times each intensity value occurs in the bitmap.
The LBitmap::HistoContrast function is similar to the ordinary LBitmap::ChangeContrast function, except that it uses a bitmap-specific middle value. The ordinary contrast function raises all intensity values above 128 and lowers all values below 128. The LBitmap::HistoContrast function first finds the median intensity value in the bitmap. It then uses that median value, instead of 128, as the middle value. With either of these functions, you pass a parameter to indicate how much to increase the contrast.
The LBitmap::StretchIntensity function improves the contrast of a flat image, while preserving the original number of different intensity values. Other contrast functions, where you specify the increase, can lose values at the top and bottom of the scale. This function, instead, sets the lowest intensity value to 0 and the highest to 255, then remaps the original values proportionally. If the original values already range from 0 to 255, this function has no effect.
The LBitmap::HistoEqualize function is often the most effective function for bringing out hidden details through contrast improvement. Like the LBitmap::StretchIntensity function, it remaps the intensity values to use the full range of 0 to 255. But instead of remapping the values proportionally, it uniformly redistributes the values to balance the number of pixels across the range of intensities. Thus, clusters of similar intensity values in the original image are spread out, enabling you to see differences that were too subtle in the original.
The LBitmap::AutoColorLevel function darkens dark values and lightens light values, enhancing shadows and brightening the image automatically.
The LBitmap::ColorLevel function applies color leveling to an image. It changes the image's shadows, midtones and highlights.
The LBitmap::LocalHistoEqualize function linearizes the number of pixels locally in a bitmap, based on the specified color space. This can be used to bring out the detail in dark areas of an image, and smooth the edges between blocks.
The LBitmap::LightControl lightens or darkens all or part of a bitmap by remapping the pixel values. This function remaps the pixel values of the bitmap across the full range of available pixel values, in order to achieve the new average values passed in puLowerAvr, puAverage and puUpperAvr.
To create your own histogram-based function, you can use the LBitmap::GetHistogram function to get a bitmap's histogram. You can then manipulate the histogram to create a lookup table and call the LBitmap::RemapIntensity function to change the bitmap's intensities through the lookup table. The LBitmap::GetFunctionalLookupTable and LBitmap::GetUserLookupTable functions provide means for programmatically updating lookup tables before calling LBitmap::RemapIntensity. You can also use the LBitmap::GetHistogram function to get the histogram for a 12- or 16-bit grayscale image. Please note that support for 12- and 16-bit grayscale images is only available in the Document/Medical toolkits.
The intensity values are gray-level values. When changing the intensity values of a color image, the LEADTOOLS functions are actually changing the value of each color plane. The high-level functions automatically change the values of all planes, but if you create your own function, the decision is up to you. With the LBitmap::GetHistogram and LBitmap::RemapIntensity functions, you can manipulate an individual color plane, or you can manipulate all color planes by specifying the master channel.
With color images, you can preserve more natural colors by first using the LBitmap::ColorSeparate function to do an HSV separation. You can then manipulate the value plane and recombine the color planes with the LBitmap::ColorMerge function.
When working with DICOM files, you can remap pixel values using a lookup table, or by applying a linear transformation using LBitmap::ApplyModalityLUT or LBitmap::ApplyLinearModalityLUT, respectively. You can also set up window leveling options for a bitmap using a lookup table or a linear transformation using LBitmap::ApplyVOILUT or LBitmap::ApplyLinearVOILUT, respectively.
The following functions make special use of the master channel:
In order to speed up widely used image processing filters in LEADTOOLS, the grayscale value (master channel) of a colored image is calculated using the following formulas:
#define CalcGrayValue(r, g, b) ((L_UCHAR)(((L_UCHAR) (((2 * (L_UINT) (r)) + (5 * (L_UINT) (g)) + (L_UINT) (b) + 4) / 8))))
#define CalcGrayValue16(r, g, b) ((L_UINT16) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
#define CalcGrayValue32(r, g, b) ((L_UINT32) (((2 * (L_UINT32) (r)) + (5 * (L_UINT32) (g)) + (L_UINT32) (b) + 4) / 8))
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document