Changing Brightness and Contrast

Show in webframe

Basic Brightness and Contrast methods

With the basic brightness and contrast command classes 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 command classes either to the display or to a image.

To adjust the display, use the PaintIntensity, PaintContrast, and PaintGamma properties. These methods affect the display of all images. They are not really part of the image processing group, because they do not affect the image. Nevertheless, these methods can be more useful than the image processing methods when the need for brightness and contrast improvement is device-specific, rather than image-specific.

To change the brightness and contrast of an image, use the ChangeIntensityCommand, ChangeContrastCommand and GammaCorrectCommand. If you use these command classes, the changes become permanent when you save the image in a file.

The AddCommand class can be used to improve the brightness of an image by adding images within an image list. The images in the list consist of several "versions" of the same view or image.

The AddWeightedCommand class can be used to improve the brightness of an image by adding images within an image list. Typically, you would use this command for a series of images taken for the same object at short intervals. This class can also be used to obtain an image as the sum of several weighted images.

The MultiplyCommand class can be used to increase or decrease the brightness in the image by multiplying the colors in the specified image by a value equal to the Factor value divided by 100. For example, if Factor is 131 the colors in the specified image will be multiplied by 1.31.

The ColorIntensityBalanceCommand class changes the distribution of the red, green, or blue channels.

The ContrastBrightnessIntensityCommand class applies brightness, contrast and intensity adjustments to enhance the image tonal range.

The ChangeHueSaturationIntensityCommand class can be used to change the hue, saturation and brightness of all or specified colors in the image. This class combines the methodality found in the ChangeHueCommand, ChangeSaturationCommand, and ChangeIntensityCommand classes 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 ApplyMathematicalLogicCommand and MathematicalFunctionCommand classes can be used to adjust the hue, saturation and brightness of an image by applying mathematical methods to an image's pixel values, including: square, square root, log, sine, and cosine and then multiplying the results by specified factor.

When working with DICOM files, you can remap pixel values using a LookupTable, or by applying a linear transformation using ApplyModalityLookupTableCommand or ApplyLinearModalityLookupTableCommand, respectively. You can also set up window-leveling options for an image using a LookupTable or a linear transformation using ApplyVoiLookupTableCommand or ApplyLinearVoiLookupTableCommand, respectively.

Histogram-Based Contrast methods

Some image processing methods 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 image.

The HistogramContrastCommand class is similar to the ordinary ChangeContrastCommand class, except that it uses an image-specific middle value. The ordinary contrast class raises all intensity values above 128 and lowers all values below 128. The HistogramContrastCommand class first finds the median intensity value in the image. It then uses that median value, instead of 128, as the middle value. With either of these classes, you specify a parameter to indicate how much to increase the contrast.

The StretchIntensityCommand class improves the contrast of a flat image, while preserving the original number of different intensity values. Other contrast classes, where you specify the increase, can lose values at the top and bottom of the scale. This class, 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 method has no effect.

The LocalHistogramEqualizeCommand class linearizes the number of pixels locally in an image, 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 HistogramEqualizeCommand class is often the most effective method for bringing out hidden details through contrast improvement. Like the StretchIntensityCommand class, 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 LightControlCommand class lightens or darkens all or part of an image by remapping the pixel values. This classremaps the pixel values of the image across the full range of available pixel values, in order to achieve the new average values

The AutoColorLevelCommand class darkens dark values and lightens light values, enhancing shadows and brightening the image automatically.

The ColorLevelCommand class applies color leveling to an image. It changes the image's shadows, midtones and highlights.

To create your own histogram-based method, you can use the HistogramCommand class to get an image's histogram. You can then manipulate the histogram to create a LookupTable and use the RemapIntensityCommand class to change the image's intensities through the lookup table. The GetFunctionalLookupTable and GetUserLookupTable classes provide a means of programmatically updating LookupTables before using RemapIntensityCommand.

To get the histogram for a 12 or 16-bit grayscale image, call HistogramCommand 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 classes are actually changing the value of each color plane. The high-level classes automatically change the values of all planes, but if you create your own class, the decision is up to you. With the HistogramCommand and RemapIntensityCommand classes, 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 ColorSeparateCommand method to do an HSV separation. You can then manipulate the value plane and recombine the color planes with the ColorMergeCommand method.

In HSV color space, a color is represented by a hue, a saturation (amount of white) and a value (amount of darkness). These can be remapped using the RemapHueCommand class. To convert between the HSV and RGB color space, use ToRasterColor and FromRasterColor.

Special methods

The DynamicBinaryCommand class converts an image 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 MultiScaleEnhancementCommand class wraps techniques of image enhancements, such as contrast enhancement, edge enhancement and latitude reduction, for Computed Radiography (CR).

The SubtractBackgroundCommand is useful, especially with medical images and grayscale images, in correcting nonuniform brightness. This method 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 method includes the methodality similar to that of the MultiplyCommand in order to include the capability for increasing the brightness of the final image.

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 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 specified through LowBit and HighBit and the user-defined color map is passed through the LookupTable property. To help set up a bit range and a color map, LEADTOOLS provides 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 with a color gradient based on the specified values. For more information, refer to the individual entries for the methods and classes. 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.

Only TIFF and DICOM file formats are capable of saving images that have been window-leveled. Images can be window-leveled by using WindowLevel and specifying RasterWindowLevelMode.PaintAndProcessing for the flags parameter or by loading an image from a file format that supports window-leveling. If a window-leveled image is saved as any other file format, the image data will be converted before being saved. For more information, refer to Saving Window-Leveled Bitmaps.

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.