本文簡要介紹 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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。