本文簡要介紹 python 語言中 scipy.ndimage.minimum_position
的用法。
用法:
scipy.ndimage.minimum_position(input, labels=None, index=None)#
在標簽處查找數組值的最小值的位置。
- input: array_like
Array_like 值。
- labels: 數組,可選
一個整數數組,標記不同區域,在這些區域上計算輸入最小值的位置。標簽必須與輸入具有相同的形狀。如果未指定標簽,則返回整個數組中第一個最小值的位置。
標簽參數僅在指定索引時才有效。
- index: 數組,可選
查找最小值位置時考慮的區域標簽列表。如果 index 是無,則
first
所有元素的最小值標簽返回非零。index 參數僅在指定標簽時有效。
- output: 整數元組列表
整數元組或整數元組列表,它們指定輸入最小值在由標簽確定的區域上的位置,並且其索引在索引中。
如果未指定索引或標簽,則返回一個整數元組,指定輸入的第一個最小值的位置。
參數 ::
返回 ::
例子:
>>> import numpy as np >>> a = np.array([[10, 20, 30], ... [40, 80, 100], ... [1, 100, 200]]) >>> b = np.array([[1, 2, 0, 1], ... [5, 3, 0, 4], ... [0, 0, 0, 7], ... [9, 3, 0, 0]])
>>> from scipy import ndimage
>>> ndimage.minimum_position(a) (2, 0) >>> ndimage.minimum_position(b) (0, 2)
可以使用標簽和索引指定要處理的特征:
>>> label, pos = ndimage.label(a) >>> ndimage.minimum_position(a, label, index=np.arange(1, pos+1)) [(2, 0)]
>>> label, pos = ndimage.label(b) >>> ndimage.minimum_position(b, label, index=np.arange(1, pos+1)) [(0, 0), (0, 3), (3, 1)]
相關用法
- Python SciPy ndimage.minimum_filter用法及代碼示例
- Python SciPy ndimage.minimum_filter1d用法及代碼示例
- Python SciPy ndimage.minimum用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy ndimage.maximum_filter1d用法及代碼示例
- Python SciPy ndimage.map_coordinates()用法及代碼示例
- Python SciPy ndimage.maximum_filter用法及代碼示例
- Python SciPy ndimage.median用法及代碼示例
- Python SciPy ndimage.maximum用法及代碼示例
- Python SciPy ndimage.map_coordinates用法及代碼示例
- Python SciPy ndimage.mean用法及代碼示例
- Python SciPy ndimage.maximum_position用法及代碼示例
- Python SciPy ndimage.median_filter用法及代碼示例
- 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.minimum_position。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。