HistogramEqualizationOptions Class
Immutable options of a histogram equalization (ImageProcessingExtensions.Equalize).
public sealed class HistogramEqualizationOptionsRemarks
The histograms have one bin per sample level: 256 for 8-bit pixel formats, 65,536 for 16-bit ones, so no precision is lost. Fully transparent pixels are not counted (the color they hide does not take part in the contrast), but they are remapped like the others.
The adaptive mode clips the histogram of a tile in 256 bins whatever the depth, as MATLAB's adapthisteq and scikit-image's equalize_adapthist do by default, so that HistogramEqualizationOptions.ClipLimit controls 16-bit frames as it controls their 8-bit versions. A bin of 16-bit samples covers 256 levels: the samples it keeps after the clip follow the histogram of its levels, and the samples it gets from the excess are spread evenly over its levels, so the mapping keeps every level. Without limit, the mapping is the one of the histogram of the 65,536 levels.
The adaptive mode follows the contrast-limited adaptive histogram equalization of K. Zuiderveld ("Contrast Limited Adaptive Histogram Equalization", Graphics Gems IV, 1994): the mapping of a tile is round(cdf(v) * max / n), where n is the number of counted samples of the tile, after its histogram is clipped, rounded to the nearest level. The tables are interpolated at the center of each pixel, ties rounded upward. On 8-bit frames whose dimensions are multiples of the tile counts, the tables are those of OpenCV's createCLAHE with the same clip limit and tile grid, but OpenCV interpolates them at the top-left corner of each pixel: the results differ by a fraction of the difference between neighboring tiles, a few levels. OpenCV also pads the other frames by reflection to whole tiles, where the tiles of the library divide the frame as evenly as possible. OpenCV clips 16-bit histograms in 65,536 bins, where the limit of a tile of fewer than 65,536 / ClipLimit samples is one sample per level: most clip limits then give the same result.
Constructors
| Name | Description |
|---|---|
| HistogramEqualizationOptions() |
HistogramEqualizationOptions()
HistogramEqualizationOptions.cspublic HistogramEqualizationOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| ClipLimit | Gets the contrast limit of the adaptive mode, as a multiple of the average bin height of a tile. Defaults to 2. The histogram of a tile is clipped in 256 bins, each one 8-bit level or 256 16-bit levels: a bin of a tile of n counted samples holds at most max(1, floor(ClipLimit * n / 256)) samples; the excess is spread over every bin as Zuiderveld does: each bin gets the same share, then the remainder r of the division goes one sample at a time to every max(1, floor(256 / r))-th bin, from bin 0. For 8-bit samples, this is the clip limit of OpenCV's createCLAHE. A tile of fewer than 256 / ClipLimit samples is limited to one sample per bin, so close clip limits can give the same result on small tiles. Double.PositiveInfinity disables the limit (plain adaptive histogram equalization). Ignored by the global mode. |
| ColorMode | Gets the samples that are remapped. Defaults to HistogramColorMode.Luminance, which keeps the hues. |
| Default | Gets the default options: a global equalization of the luminance of each frame. |
| Mode | Gets the algorithm. Defaults to HistogramEqualizationMode.Global. |
| ShareHistogramAcrossFrames | Gets a value indicating whether every frame of an image, and its poster frame, is remapped with the histograms of all of them together, so that the frames of an animation get the same mapping and do not flicker. Defaults to false: each frame is equalized alone. Ignored when one frame is equalized. |
| TileCountX | Gets the number of columns of tiles of the adaptive mode, from 1 to HistogramEqualizationOptions.MaxTileCount. Defaults to 8. A frame narrower than that has one column of tiles per pixel column. Tile k covers the pixel columns from floor(k * width / count) included to floor((k + 1) * width / count) excluded. Ignored by the global mode. |
| TileCountY | Gets the number of rows of tiles of the adaptive mode, from 1 to HistogramEqualizationOptions.MaxTileCount. Defaults to 8. A frame shorter than that has one row of tiles per pixel row. Ignored by the global mode. |
ClipLimit
HistogramEqualizationOptions.csGets the contrast limit of the adaptive mode, as a multiple of the average bin height of a tile. Defaults to 2. The histogram of a tile is clipped in 256 bins, each one 8-bit level or 256 16-bit levels: a bin of a tile of n counted samples holds at most max(1, floor(ClipLimit * n / 256)) samples; the excess is spread over every bin as Zuiderveld does: each bin gets the same share, then the remainder r of the division goes one sample at a time to every max(1, floor(256 / r))-th bin, from bin 0. For 8-bit samples, this is the clip limit of OpenCV's createCLAHE. A tile of fewer than 256 / ClipLimit samples is limited to one sample per bin, so close clip limits can give the same result on small tiles. Double.PositiveInfinity disables the limit (plain adaptive histogram equalization). Ignored by the global mode.
public double ClipLimit { get; init; }ColorMode
HistogramEqualizationOptions.csGets the samples that are remapped. Defaults to HistogramColorMode.Luminance, which keeps the hues.
public HistogramColorMode ColorMode { get; init; }Gets the default options: a global equalization of the luminance of each frame.
public static HistogramEqualizationOptions Default { get; }Property value
Gets the algorithm. Defaults to HistogramEqualizationMode.Global.
public HistogramEqualizationMode Mode { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not a defined
HistogramEqualizationMode.
TileCountX
HistogramEqualizationOptions.csGets the number of columns of tiles of the adaptive mode, from 1 to HistogramEqualizationOptions.MaxTileCount. Defaults to 8. A frame narrower than that has one column of tiles per pixel column. Tile k covers the pixel columns from floor(k * width / count) included to floor((k + 1) * width / count) excluded. Ignored by the global mode.
public int TileCountX { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not between 1 and
HistogramEqualizationOptions.MaxTileCount.
TileCountY
HistogramEqualizationOptions.csGets the number of rows of tiles of the adaptive mode, from 1 to HistogramEqualizationOptions.MaxTileCount. Defaults to 8. A frame shorter than that has one row of tiles per pixel row. Ignored by the global mode.
public int TileCountY { get; init; }Property value
Exceptions
ArgumentOutOfRangeException- The value is not between 1 and
HistogramEqualizationOptions.MaxTileCount.
Constants
| Name | Description |
|---|---|
| MaxTileCount | The largest number of tiles along an axis. |
MaxTileCount
The largest number of tiles along an axis.
public const int MaxTileCount = 256