本文簡要介紹 python 語言中 scipy.ndimage.median
的用法。
用法:
scipy.ndimage.median(input, labels=None, index=None)#
計算標記區域上數組值的中位數。
- input: array_like
Array_like 值。對於標簽指定的每個區域,計算該區域上輸入的中值。
- labels: 數組,可選
一個整數數組,標記要計算輸入中值的不同區域。標簽必須與輸入具有相同的形狀。如果未指定標簽,則返回整個數組的中位數。
- index: 數組,可選
計算中位數時考慮的區域標簽列表。如果 index 為 None,則返回標簽非零的所有元素的中值。
- median: 浮點數或浮點數列表
由標簽確定且索引位於索引中的區域的輸入中位數列表。如果未指定索引或標簽,則返回浮點數:如果標簽為 None,則返回輸入的中值;如果索引為 None,則返回 labels 大於零的元素的中值。
參數 ::
返回 ::
注意:
該函數返回一個 Python 列表,而不是 NumPy 數組,請使用 np.array 將列表轉換為數組。
例子:
>>> from scipy import ndimage >>> import numpy as np >>> a = np.array([[1, 2, 0, 1], ... [5, 3, 0, 4], ... [0, 0, 0, 7], ... [9, 3, 0, 0]]) >>> labels, labels_nb = ndimage.label(a) >>> labels array([[1, 1, 0, 2], [1, 1, 0, 2], [0, 0, 0, 2], [3, 3, 0, 0]]) >>> ndimage.median(a, labels=labels, index=np.arange(1, labels_nb + 1)) [2.5, 4.0, 6.0] >>> ndimage.median(a) 1.0 >>> ndimage.median(a, labels=labels) 3.0
相關用法
- Python SciPy ndimage.median_filter用法及代碼示例
- Python SciPy ndimage.mean用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy ndimage.maximum_filter1d用法及代碼示例
- Python SciPy ndimage.map_coordinates()用法及代碼示例
- Python SciPy ndimage.maximum_filter用法及代碼示例
- Python SciPy ndimage.minimum_position用法及代碼示例
- Python SciPy ndimage.minimum用法及代碼示例
- Python SciPy ndimage.maximum用法及代碼示例
- Python SciPy ndimage.map_coordinates用法及代碼示例
- Python SciPy ndimage.maximum_position用法及代碼示例
- Python SciPy ndimage.minimum_filter用法及代碼示例
- Python SciPy ndimage.minimum_filter1d用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- 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.iterate_structure用法及代碼示例
- Python SciPy ndimage.generic_laplace用法及代碼示例
- Python SciPy ndimage.generate_binary_structure用法及代碼示例
- Python SciPy ndimage.binary_opening用法及代碼示例
- Python SciPy ndimage.binary_fill_holes用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.ndimage.median。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。