class Histogram – Histogram Object¶
The histogram object is returned by Image.get_histogram(). The underlying
class name is histogram.
For grayscale images the histogram has a single channel of bins. For RGB565
images the histogram has three channels covering the CIE-LAB L, A,
and B axes. In both cases each channel is normalized so that its bins
sum to 1.0.
Per-channel bin lists are exposed as both bound methods (hist.bins())
and through subscript notation (hist[0]). The high-level reductions
get_percentile(), get_threshold(), and get_statistics()
return the corresponding Percentile,
Threshold, and Statistics attrtuples.
- class image.histogram¶
Please call
Image.get_histogram()to create this object. It has no public constructor.- bins() list[float]¶
Return the bin list for a grayscale histogram. Each entry is in the range 0.0 to 1.0 and the entries sum to 1.0.
Equivalent to
histogram[0].
- l_bins() list[float]¶
Return the bin list for the LAB
Lchannel of an RGB565 histogram. Each entry is in the range 0.0 to 1.0 and the entries sum to 1.0.Equivalent to
histogram[0].
- a_bins() list[float]¶
Return the bin list for the LAB
Achannel of an RGB565 histogram. Each entry is in the range 0.0 to 1.0 and the entries sum to 1.0.Equivalent to
histogram[1].
- b_bins() list[float]¶
Return the bin list for the LAB
Bchannel of an RGB565 histogram. Each entry is in the range 0.0 to 1.0 and the entries sum to 1.0.Equivalent to
histogram[2].
- get_percentile(percentile: float) image.percentile¶
Compute the CDF of every histogram channel and return the bin value at the requested
percentile(a float in0.0–1.0).Useful for finding the min/max of a color distribution while ignoring outliers (
get_percentile(0.05)andget_percentile(0.95)give a robust min/max).Returns a
Percentileattrtuple.
- get_threshold() image.threshold¶
Use Otsu’s Method on every channel to find the threshold value that best splits each channel’s distribution into a “background” and “foreground” half. The returned thresholds are well-suited to feed directly into
Image.binary()or any other method that takes LABL/A/Bcolor thresholds.Returns a
Thresholdattrtuple.
- get_statistics() image.statistics¶
Compute the mean, median, mode, standard deviation, min, max, lower quartile, and upper quartile of every histogram channel.
Returns a
Statisticsattrtuple.
- get_stats() image.statistics¶
Alias for
get_statistics().
- statistics() image.statistics¶
Alias for
get_statistics().