用法:
cucim.skimage.feature.canny(image, sigma=1.0, low_threshold=None, high_threshold=None, mask=None, use_quantiles=False)
使用 Canny 算法對圖像進行邊過濾。
- image:二維數組
灰度輸入圖像以檢測邊;可以是任何 dtype。
- sigma:浮點數,可選
高斯濾波器的標準偏差。
- low_threshold:浮點數,可選
滯後閾值(鏈接邊)的下限。如果沒有,low_threshold 設置為 dtype 最大值的 10%。
- high_threshold:浮點數,可選
滯後閾值的上限(鏈接邊)。如果沒有,high_threshold 設置為 dtype 最大值的 20%。
- mask:數組,dtype=bool,可選
將 Canny 的應用限製在某個區域的掩碼。
- use_quantiles:布爾型,可選
如果為 True,則將 low_threshold 和 high_threshold 視為邊幅度圖像的分位數,而不是絕對邊幅度值。如果為 True,則閾值必須在 [0, 1] 範圍內。
- output:二維數組(圖像)
二元邊圖。
參數:
返回:
注意:
該算法的步驟如下:
- 使用具有
sigma
寬度的高斯平滑圖像。 - 應用水平和垂直 Sobel 算子來獲得圖像中的漸變。邊強度是梯度的範數。
- 將潛在邊細化到 1 像素寬的曲線。首先,在每個點找到邊的法線。這是通過查看X-Sobel 和Y-Sobel 的符號和相對幅度來完成的,將點分為4 類:水平、垂直、對角線和對角線。然後查看正常和反向方向,看看其中任何一個方向的值是否大於所討論的點。使用插值來獲得混合點,而不是選擇最接近法線的點。
- 執行滯後閾值處理:首先將高於高閾值的所有點標記為邊。然後遞歸地將任何高於低閾值的點標記為 8 連接到標記點作為邊。
參考:
- 1
Canny, J., A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986 DOI:10.1109/TPAMI.1986.4767851
- 2
William Green’s Canny tutorial https://en.wikipedia.org/wiki/Canny_edge_detector
例子:
>>> import cupy as cp >>> from cucim.skimage import feature >>> # Generate noisy image of a square >>> im = cp.zeros((256, 256)) >>> im[64:-64, 64:-64] = 1 >>> im += 0.2 * cp.random.rand(*im.shape) >>> # First trial with the Canny filter, with the default smoothing >>> edges1 = feature.canny(im) >>> # Increase the smoothing for better results >>> edges2 = feature.canny(im, sigma=3)
相關用法
- Python cucim.skimage.feature.corner_foerstner用法及代碼示例
- Python cucim.skimage.feature.corner_shi_tomasi用法及代碼示例
- Python cucim.skimage.feature.corner_peaks用法及代碼示例
- Python cucim.skimage.feature.corner_kitchen_rosenfeld用法及代碼示例
- Python cucim.skimage.feature.corner_harris用法及代碼示例
- Python cucim.skimage.feature.shape_index用法及代碼示例
- Python cucim.skimage.feature.structure_tensor_eigenvalues用法及代碼示例
- Python cucim.skimage.feature.peak_local_max用法及代碼示例
- Python cucim.skimage.feature.match_template用法及代碼示例
- Python cucim.skimage.feature.structure_tensor_eigvals用法及代碼示例
- Python cucim.skimage.feature.hessian_matrix_eigvals用法及代碼示例
- Python cucim.skimage.feature.hessian_matrix用法及代碼示例
- 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.canny。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。