Table of Contents

Class Histogram

Namespace
Egami.Analysis
Assembly
Egami.dll

How many pixels of a frame have each value of one channel, in equal bins over 0 to 1, from Histogram(ColorChannel, int, int).

public sealed class Histogram
Inheritance
Histogram
Inherited Members

Examples

// How the brightness is spread: 256 bins, and the levels below which 1% and 99% of the pixels lie.
Histogram histogram = photo.Histogram(ColorChannel.Luminance);
double shadows = histogram.Percentile(0.01), highlights = histogram.Percentile(0.99);
long midtones = histogram.Counts.Skip(64).Take(128).Sum();

Properties

Bins

Gets the number of bins.

public int Bins { get; }

Property Value

int

Counts

Gets the count of each bin: bin i holds values from i / Bins up to (i + 1) / Bins, and the last bin also holds 1.

public IReadOnlyList<long> Counts { get; }

Property Value

IReadOnlyList<long>

Median

Gets the median level, Percentile(double)(0.5): the lower middle value when the count is even.

public double Median { get; }

Property Value

double

Total

Gets the number of pixels counted.

public long Total { get; }

Property Value

long

Methods

Percentile(double)

Returns the value below which a fraction p of the pixels lie: the level i / (Bins − 1) of the first bin at which the running count reaches p × Total. With 256 bins on 8-bit data, the level is the 8-bit value / 255.

public double Percentile(double p)

Parameters

p double

The fraction, from 0 to 1.

Returns

double

The level, from 0 to 1.

Exceptions

ArgumentOutOfRangeException

p is outside 0 to 1.