用法:
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,則選擇兩者中的最大值作為峰值的最小強度閾值。
- image:ndarray
輸入圖像。
- min_distance:int 可選
分離峰的最小允許距離。要查找最大峰數,請使用min_distance=1。
- threshold_abs:浮點數或無,可選
峰的最小強度。默認情況下,絕對閾值是圖像的最小強度。
- threshold_rel:浮點數或無,可選
峰的最小強度,計算為
max(image) * threshold_rel
。- exclude_border:int 整數元組或布爾值,可選
如果是正整數,exclude_border 會排除圖像邊界 exclude_border-像素內的峰值。如果元組是非負整數,則元組的長度必須與輸入數組的維度匹配。元組的每個元素將排除沿該維度的圖像邊界的exclude_border-像素內的峰值。如果為 True,則將 min_distance 參數作為值。如果為零或假,無論峰與邊界的距離如何,都可以識別峰。
- indices:布爾型,可選
如果為 True,則輸出將是一個表示峰值坐標的數組。坐標根據峰值排序(較大的優先)。如果為 False,則輸出將是一個布爾數組,其形狀為image.shape在真元素處出現峰值。
indices
已棄用並將在 0.20 版中刪除。默認行為將始終返回峰值坐標。您可以獲得如下示例所示的掩碼。- num_peaks:int 可選
最大峰值數。當峰數超過num_peaks時,根據最高峰強度返回num_peaks峰。
- footprint:布爾數組,可選
如果提供,footprint == 1 表示要在圖像中的每個點搜索峰值的局部區域。
- labels:整數的ndarray,可選
如果提供,每個唯一區域標簽 == 值代表一個用於搜索峰值的唯一區域。零是為背景保留的。
- num_peaks_per_label:int 可選
每個標簽的最大峰值數。
- p_norm:浮點數
使用哪個 Minkowski p-norm。應在 [1, inf] 範圍內。如果可能發生溢出,有限的大 p 可能會導致 ValueError。
inf
對應於切比雪夫距離,2 對應於歐幾裏得距離。
- output:ndarray 或 ndarray 的布爾值
- 如果 index =真:(行,列,...)峰坐標。
- 如果 index =假: 布爾數組形狀像圖片, 峰值由 True 值表示。
參數:
返回:
注意:
峰值局部最大值函數返回圖像中局部峰值(最大值)的坐標。在內部,最大過濾器用於尋找局部最大值。此操作會擴大原始圖像。在比較擴張圖像和原始圖像之後,此函數返回擴張圖像等於原始圖像的峰的坐標或掩碼。
例子:
>>> img1 = np.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 = np.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 = np.zeros_like(img2, dtype=bool) >>> peak_mask[tuple(peak_idx.T)] = True >>> np.argwhere(peak_mask) array([[10, 10, 10], [15, 15, 15]])
相關用法
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
- Python skimage.feature.blob_dog用法及代碼示例
- Python skimage.feature.graycoprops用法及代碼示例
- Python skimage.feature.corner_orientations用法及代碼示例
- Python skimage.feature.structure_tensor用法及代碼示例
- Python skimage.feature.hessian_matrix用法及代碼示例
- Python skimage.feature.ORB用法及代碼示例
- Python skimage.feature.corner_subpix用法及代碼示例
- Python skimage.feature.canny用法及代碼示例
- Python skimage.feature.CENSURE用法及代碼示例
- Python skimage.feature.hessian_matrix_eigvals用法及代碼示例
- Python skimage.feature.corner_foerstner用法及代碼示例
- Python skimage.feature.haar_like_feature_coord用法及代碼示例
- Python skimage.feature.corner_harris用法及代碼示例
- Python skimage.feature.corner_fast用法及代碼示例
- Python skimage.feature.BRIEF用法及代碼示例
- Python skimage.feature.haar_like_feature用法及代碼示例
- Python skimage.feature.SIFT用法及代碼示例
- Python skimage.feature.structure_tensor_eigvals用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.feature.peak_local_max。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。