当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python skimage.exposure.histogram用法及代码示例


用法:

skimage.exposure.histogram(image, nbins=256, source_range='image', normalize=False, *, channel_axis=None)

返回图像的直方图。

numpy.histogram 不同,此函数返回 bin 的中心,并且不会重新组合整数数组。对于整数数组,每个整数值都有自己的 bin,这提高了速度和强度分辨率。

如果channel_axis未设置,直方图是在展平图像上计算的。对于彩色或多通道图像,设置channel_axis为所有通道使用公共分箱。或者,可以在每个通道上单独应用该函数,以获得具有单独分箱的每个颜色通道的直方图。

参数

image数组

输入图像。

nbinsint 可选

用于计算直方图的 bin 数量。对于整数数组,此值将被忽略。

source_range字符串,可选

‘image’(默认)确定输入图像的范围。 ‘dtype’ 确定该数据类型图像的预期范围。

normalize布尔型,可选

如果为 True,则通过其值的总和对直方图进行归一化。

channel_axisint 或无,可选

如果为 None,则假定图像是灰度(单通道)图像。否则,此参数指示数组的哪个轴对应于通道。

返回

hist数组

直方图的值。当channel_axis 不是 None 时, hist 将是一个二维数组,其中第一个轴对应于通道。

bin_centers数组

bin 中心的值。

例子

>>> from skimage import data, exposure, img_as_float
>>> image = img_as_float(data.camera())
>>> np.histogram(image, bins=2)
(array([ 93585, 168559]), array([0. , 0.5, 1. ]))
>>> exposure.histogram(image, nbins=2)
(array([ 93585, 168559]), array([0.25, 0.75]))

相关用法


注:本文由纯净天空筛选整理自scikit-image.org大神的英文原创作品 skimage.exposure.histogram。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。