本文簡要介紹 python 語言中 scipy.ndimage.variance
的用法。
用法:
scipy.ndimage.variance(input, labels=None, index=None)#
計算 N-D 圖像數組的值的方差,可選地在指定的 sub-regions 處。
- input: array_like
Nd-image 要處理的數據。
- labels: 數組,可選
在輸入中定義 sub-regions 的標簽。如果不是無,則必須與輸入的形狀相同。
- index: int 或整數序列,可選
要包含在輸出中的標簽。如果無(默認),則使用標簽非零的所有值。
- variance: 浮點數或 ndarray
如果指定了標簽和索引,則為每個 sub-region 的方差值。
參數 ::
返回 ::
例子:
>>> import numpy as np >>> a = np.array([[1, 2, 0, 0], ... [5, 3, 0, 4], ... [0, 0, 0, 7], ... [9, 3, 0, 0]]) >>> from scipy import ndimage >>> ndimage.variance(a) 7.609375
可以使用標簽和索引指定要處理的特征:
>>> lbl, nlbl = ndimage.label(a) >>> ndimage.variance(a, lbl, index=np.arange(1, nlbl+1)) array([ 2.1875, 2.25 , 9. ])
如果沒有給出索引,則處理所有非零標簽:
>>> ndimage.variance(a, lbl) 6.1875
相關用法
- Python SciPy ndimage.value_indices用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- 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.variance。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。