AutoLevelsOptions Class
Immutable options of a contrast stretch (ImageProcessingExtensions.AutoLevels).
public sealed class AutoLevelsOptionsRemarks
The stretch finds the low level lo, the smallest level v such that more than AutoLevelsOptions.LowPercentile percent of the counted samples are at most v, and the high level hi, the largest level v such that more than 100 - AutoLevelsOptions.HighPercentile percent of them are at least v. A level v then becomes round((v - lo) * max / (hi - lo)), clamped to the sample range, where max is the largest sample value (255 or 65,535). With the default percentiles, lo and hi are the darkest and the brightest levels present. When hi is not above lo, nothing changes.
The histograms have one bin per sample level: 256 for 8-bit pixel formats, 65,536 for 16-bit ones. Fully transparent pixels are not counted, but they are remapped like the others.
Constructors
| Name | Description |
|---|---|
| AutoLevelsOptions() |
AutoLevelsOptions()
AutoLevelsOptions.cspublic AutoLevelsOptions()No documentation is available.
Properties
| Name | Description |
|---|---|
| ColorMode | Gets the samples that are stretched. Defaults to HistogramColorMode.Luminance, which keeps the hues; HistogramColorMode.PerChannel stretches each channel from its own levels, which also removes a color cast. |
| Default | Gets the default options: the luminance of each frame is stretched from its darkest to its brightest level. |
| HighPercentile | Gets the percentile of the high level: 100 - HighPercentile percent of the samples may be brighter than it and become the largest sample value. Defaults to 100. |
| LowPercentile | Gets the share of the samples, in percent, that may be darker than the low level and become 0. Defaults to 0. It must be less than AutoLevelsOptions.HighPercentile, which the operation checks. |
| ShareHistogramAcrossFrames | Gets a value indicating whether every frame of an image, and its poster frame, is stretched with the levels 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 stretched alone. Ignored when one frame is stretched. |
ColorMode
AutoLevelsOptions.csGets the samples that are stretched. Defaults to HistogramColorMode.Luminance, which keeps the hues; HistogramColorMode.PerChannel stretches each channel from its own levels, which also removes a color cast.
public HistogramColorMode ColorMode { get; init; }Default
AutoLevelsOptions.csGets the default options: the luminance of each frame is stretched from its darkest to its brightest level.
public static AutoLevelsOptions Default { get; }Property value
HighPercentile
AutoLevelsOptions.csGets the percentile of the high level: 100 - HighPercentile percent of the samples may be brighter than it and become the largest sample value. Defaults to 100.
public double HighPercentile { get; init; }LowPercentile
AutoLevelsOptions.csGets the share of the samples, in percent, that may be darker than the low level and become 0. Defaults to 0. It must be less than AutoLevelsOptions.HighPercentile, which the operation checks.
public double LowPercentile { get; init; }