本文简要介绍 python 语言中 scipy.ndimage.histogram
的用法。
用法:
scipy.ndimage.histogram(input, min, max, bins, labels=None, index=None)#
计算数组值的直方图,可选择在标签处。
直方图计算数组中值在由 min、max 和 bin 确定的 bin 内的频率。标签和索引关键字可以将直方图的范围限制在数组中指定的sub-regions。
- input: array_like
为其计算直方图的数据。
- min, max: int
直方图 bin 范围的最小值和最大值。
- bins: int
箱子的数量。
- labels: 数组,可选
输入对象的标签。如果不是无,则必须与输入的形状相同。
- index: int 或整数序列,可选
要计算直方图的标签。如果为 None,则使用 label 大于零的所有值
- hist: ndarray
直方图计数。
参数 ::
返回 ::
例子:
>>> import numpy as np >>> a = np.array([[ 0. , 0.2146, 0.5962, 0. ], ... [ 0. , 0.7778, 0. , 0. ], ... [ 0. , 0. , 0. , 0. ], ... [ 0. , 0. , 0.7181, 0.2787], ... [ 0. , 0. , 0.6573, 0.3094]]) >>> from scipy import ndimage >>> ndimage.histogram(a, 0, 1, 10) array([13, 0, 2, 1, 0, 1, 1, 2, 0, 0])
使用标签且没有索引时,计算非零元素:
>>> lbl, nlbl = ndimage.label(a) >>> ndimage.histogram(a, 0, 1, 10, lbl) array([0, 0, 2, 1, 0, 1, 1, 2, 0, 0])
索引可用于仅计算某些对象:
>>> ndimage.histogram(a, 0, 1, 10, lbl, 2) array([0, 0, 1, 1, 0, 0, 1, 1, 0, 0])
相关用法
- Python SciPy ndimage.correlate用法及代码示例
- Python SciPy ndimage.morphological_gradient用法及代码示例
- Python SciPy ndimage.variance用法及代码示例
- Python SciPy ndimage.correlate1d用法及代码示例
- Python SciPy ndimage.binary_dilation用法及代码示例
- Python SciPy ndimage.distance_transform_bf用法及代码示例
- Python SciPy ndimage.find_objects用法及代码示例
- Python SciPy ndimage.label用法及代码示例
- Python SciPy ndimage.maximum_filter1d用法及代码示例
- Python SciPy ndimage.iterate_structure用法及代码示例
- Python SciPy ndimage.map_coordinates()用法及代码示例
- Python SciPy ndimage.generic_laplace用法及代码示例
- Python SciPy ndimage.generate_binary_structure用法及代码示例
- Python SciPy ndimage.binary_opening用法及代码示例
- Python SciPy ndimage.binary_fill_holes用法及代码示例
- Python SciPy ndimage.maximum_filter用法及代码示例
- Python SciPy ndimage.minimum_position用法及代码示例
- Python SciPy ndimage.labeled_comprehension用法及代码示例
- Python SciPy ndimage.grey_erosion用法及代码示例
- Python SciPy ndimage.spline_filter用法及代码示例
- Python SciPy ndimage.shift用法及代码示例
- Python SciPy ndimage.distance_transform_cdt用法及代码示例
- Python SciPy ndimage.minimum用法及代码示例
- Python SciPy ndimage.fourier_uniform用法及代码示例
- Python SciPy ndimage.gaussian_laplace用法及代码示例
注:本文由纯净天空筛选整理自scipy.org大神的英文原创作品 scipy.ndimage.histogram。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。