class Histogram -- Histogram 对象¶
直方图对象由 Image.get_histogram() 返回。底层类名为 histogram。
对于灰度图像,直方图具有单一通道的分箱。对于 RGB565 图像,直方图具有三个通道,分别对应 CIE-LAB 的 L、A 和 B 轴。在这两种情况下,每个通道都经过归一化,使其分箱总和为 1.0。
每个通道的分箱列表既以绑定方法(hist.bins())形式公开,也可通过下标表示法(hist[0])访问。高层级的归约方法 get_percentile()、get_threshold() 和 get_statistics() 分别返回对应的 Percentile、Threshold 和 Statistics attrtuple。
- class image.histogram¶
请调用
Image.get_histogram()来创建此对象。它没有公开的构造函数。- l_bins() list[float]¶
返回 RGB565 直方图中 LAB
L通道的分箱列表。每个条目的范围为 0.0 到 1.0,且各条目之和为 1.0。等价于
histogram[0]。
- a_bins() list[float]¶
返回 RGB565 直方图中 LAB
A通道的分箱列表。每个条目的范围为 0.0 到 1.0,且各条目之和为 1.0。等价于
histogram[1]。
- b_bins() list[float]¶
返回 RGB565 直方图中 LAB
B通道的分箱列表。每个条目的范围为 0.0 到 1.0,且各条目之和为 1.0。等价于
histogram[2]。
- get_percentile(percentile: float) image.percentile¶
计算每个直方图通道的 CDF,并返回所请求的
percentile(0.0--1.0范围内的浮点数)处的分箱值。适用于在忽略离群值的情况下查找颜色分布的最小/最大值(
get_percentile(0.05)和get_percentile(0.95)可给出稳健的最小/最大值)。返回一个
Percentileattrtuple。
- get_threshold() image.threshold¶
对每个通道使用大津法(Otsu's Method)来找到能最佳地将每个通道的分布划分为“背景”和“前景”两半的阈值。返回的阈值非常适合直接传入
Image.binary()或任何其他接受 LABL/A/B颜色阈值的方法。返回一个
Thresholdattrtuple。
- get_statistics() image.statistics¶
计算每个直方图通道的均值、中位数、众数、标准差、最小值、最大值、下四分位数和上四分位数。
返回一个
Statisticsattrtuple。
- get_stats() image.statistics¶
get_statistics()的别名。
- statistics() image.statistics¶
get_statistics()的别名。