class Histogram – Histogram Object

The histogram object is returned by Image.get_histogram(). The underlying class name is histogram.

Grayscale histograms have one channel with some number of bins. All bins are normalized so that they sum to 1.

RGB565 histograms have three channels (LAB L, A, B) with some number of bins each. All bins in a channel are normalized so that they sum to 1.

class image.histogram

Please call Image.get_histogram() to create this object. It has no public constructor.

bins() list[float]

Returns a list of floats for the grayscale histogram.

Also accessible as histogram[0].

l_bins() list[float]

Returns a list of floats for the RGB565 LAB L channel histogram.

Also accessible as histogram[0].

a_bins() list[float]

Returns a list of floats for the RGB565 LAB A channel histogram.

Also accessible as histogram[1].

b_bins() list[float]

Returns a list of floats for the RGB565 LAB B channel histogram.

Also accessible as histogram[2].

get_percentile(percentile: float) image.percentile

Computes the CDF of the histogram channels and returns an image.percentile object holding the value at percentile (0.0 - 1.0) for each channel. Useful for determining min/max of a color distribution while ignoring outliers.

get_threshold() image.threshold

Uses Otsu’s Method to compute the optimal threshold values that split the histogram into two halves for each channel. Returns an image.threshold object. Useful for determining optimal Image.binary() thresholds.

get_statistics() image.statistics

Computes the mean, median, mode, standard deviation, min, max, lower quartile, and upper quartile of each channel of the histogram. Returns an image.statistics object.

get_stats() image.statistics

Alias for histogram.get_statistics().

statistics() image.statistics

Alias for histogram.get_statistics().