用法:
cucim.skimage.feature.peak_local_max(image, min_distance=1, threshold_abs=None, threshold_rel=None, exclude_border=True, indices=True, num_peaks=inf, footprint=None, labels=None, num_peaks_per_label=inf, p_norm=inf)
在圖像中查找峰值作為坐標列表或布爾掩碼。
峰值是
2 * min_distance + 1
區域中的局部最大值(即,峰值至少相隔min_distance
)。如果同時提供
threshold_abs
和threshold_rel
,則選擇兩者中的最大值作為峰值的最小強度閾值。在 0.18 版中更改:在 0.18 版之前,半徑範圍內相同高度的峰
min_distance
全部返回,但這可能會導致意外行為。從 0.18 開始,返回該區域內的任意峰值。請參閱問題 gh-2592。- image:ndarray
輸入圖像。
- min_distance:整數,可選
分離峰的最小允許距離。要查找最大峰值數,請使用
min_distance=1
。- threshold_abs:浮點數,可選
峰的最小強度。默認情況下,絕對閾值是圖像的最小強度。
- threshold_rel:浮點數,可選
峰的最小強度,計算為
max(image) * threshold_rel
。- exclude_border:int,int 元組,或 bool,可選
如果是正整數,
exclude_border
會排除圖像邊界的exclude_border
-pixels 內的峰值。如果元組是非負整數,則元組的長度必須與輸入數組的維度匹配。元組的每個元素將排除exclude_border
-沿該維度的圖像邊界的像素內的峰值。如果為 True,則將min_distance
參數作為值。如果為零或假,無論峰與邊界的距離如何,都可以識別峰。- indices:布爾型,可選
如果為 True,則輸出將是一個表示峰值坐標的數組。坐標根據峰值排序(較大的優先)。如果為 False,則輸出將是一個布爾數組,其形狀為
image.shape
,峰值出現在 True 元素處。indices
已棄用,將在 0.20 版中刪除。默認行為將始終返回峰值坐標。您可以獲得如下示例所示的掩碼。- num_peaks:整數,可選
最大峰值數。當峰數超過
num_peaks
時,根據最高峰強度返回num_peaks
峰。- footprint:布爾數組,可選
如果提供,
footprint == 1
表示要在其中搜索image
中每個點的峰值的局部區域。- labels:整數的ndarray,可選
如果提供,每個唯一區域
labels == value
代表一個用於搜索峰的唯一區域。零是為背景保留的。- num_peaks_per_label:整數,可選
每個標簽的最大峰值數。
- p_norm:浮點數
使用哪個 Minkowski p-norm。應在 [1, inf] 範圍內。如果可能發生溢出,有限的大 p 可能會導致 ValueError。
inf
對應於切比雪夫距離,2 對應於歐幾裏得距離。
- output:ndarray 或 ndarray 的布爾值
- 如果
indices = True
:(行,列,...)峰坐標。 - 如果
indices = False
:布爾數組,形狀類似於image
,峰值由 True 值表示。
- 如果
參數:
返回:
注意:
峰值局部最大值函數返回圖像中局部峰值(最大值)的坐標。在內部,最大過濾器用於尋找局部最大值。此操作會擴大原始圖像。在比較擴張圖像和原始圖像之後,此函數返回擴張圖像等於原始圖像的峰的坐標或掩碼。
例子:
>>> import cupy as cp >>> img1 = cp.zeros((7, 7)) >>> img1[3, 4] = 1 >>> img1[3, 2] = 1.5 >>> img1 array([[0. , 0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 1.5, 0. , 1. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. , 0. ]])
>>> peak_local_max(img1, min_distance=1) array([[3, 2], [3, 4]])
>>> peak_local_max(img1, min_distance=2) array([[3, 2]])
>>> img2 = cp.zeros((20, 20, 20)) >>> img2[10, 10, 10] = 1 >>> img2[15, 15, 15] = 1 >>> peak_idx = peak_local_max(img2, exclude_border=0) >>> peak_idx array([[10, 10, 10], [15, 15, 15]])
>>> peak_mask = cp.zeros_like(img2, dtype=bool) >>> peak_mask[tuple(peak_idx.T)] = True >>> np.argwhere(peak_mask) array([[10, 10, 10], [15, 15, 15]])
相關用法
- Python cucim.skimage.feature.shape_index用法及代碼示例
- Python cucim.skimage.feature.corner_foerstner用法及代碼示例
- Python cucim.skimage.feature.structure_tensor_eigenvalues用法及代碼示例
- Python cucim.skimage.feature.corner_shi_tomasi用法及代碼示例
- Python cucim.skimage.feature.match_template用法及代碼示例
- Python cucim.skimage.feature.structure_tensor_eigvals用法及代碼示例
- Python cucim.skimage.feature.hessian_matrix_eigvals用法及代碼示例
- Python cucim.skimage.feature.canny用法及代碼示例
- Python cucim.skimage.feature.hessian_matrix用法及代碼示例
- Python cucim.skimage.feature.corner_peaks用法及代碼示例
- Python cucim.skimage.feature.corner_kitchen_rosenfeld用法及代碼示例
- Python cucim.skimage.feature.corner_harris用法及代碼示例
- Python cucim.skimage.feature.structure_tensor用法及代碼示例
- Python cucim.skimage.filters.roberts_neg_diag用法及代碼示例
- Python cucim.skimage.filters.gabor用法及代碼示例
- Python cucim.skimage.filters.roberts_pos_diag用法及代碼示例
- Python cucim.skimage.filters.roberts用法及代碼示例
- Python cucim.skimage.filters.gabor_kernel用法及代碼示例
- Python cucim.skimage.filters.sobel_v用法及代碼示例
- Python cucim.skimage.filters.sobel_h用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cucim.skimage.feature.peak_local_max。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。