用法:
skimage.morphology.thin(image, max_num_iter=None)
執行二值圖像的形態細化。
- image:二進製(M,N)ndarray
要細化的圖像。
- max_num_iter:int 迭代次數,可選
無論此參數的值如何,如果迭代沒有產生變化,則立即返回細化的圖像。如果指定了此參數,則它會設置執行迭代次數的上限。
- out:布爾數組
變薄的圖像。
- max_iter:DEPRECATED
已棄用以支持max_num_iter。
參數:
返回:
其他參數:
注意:
該算法 [1] 的工作原理是在圖像上進行多次傳遞,刪除與一組旨在細化連接區域的標準相匹配的像素,同時保留 eight-connected 組件和 2 x 2 正方形 [2] 。在兩個sub-iterations 中的每一個中,該算法將中間骨架圖像與鄰域掩碼相關聯,然後在查找表中查找每個鄰域,指示是否應刪除該sub-iteration 中的中心像素。
參考:
- 1
Z. Guo and R. W. Hall, “Parallel thinning with two-subiteration algorithms,” Comm. ACM, vol. 32, no. 3, pp. 359-373, 1989. DOI:10.1145/62065.62074
- 2
Lam, L., Seong-Whan Lee, and Ching Y. Suen, “Thinning Methodologies-A Comprehensive Survey,” IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol 14, No. 9, p. 879, 1992. DOI:10.1109/34.161346
例子:
>>> square = np.zeros((7, 7), dtype=np.uint8) >>> square[1:-1, 2:-2] = 1 >>> square[0, 1] = 1 >>> square array([[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]], dtype=uint8) >>> skel = thin(square) >>> skel.astype(np.uint8) array([[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
相關用法
- Python skimage.morphology.h_minima用法及代碼示例
- Python skimage.morphology.dilation用法及代碼示例
- Python skimage.morphology.remove_small_holes用法及代碼示例
- Python skimage.morphology.flood_fill用法及代碼示例
- Python skimage.morphology.black_tophat用法及代碼示例
- Python skimage.morphology.h_maxima用法及代碼示例
- Python skimage.morphology.local_maxima用法及代碼示例
- Python skimage.morphology.area_closing用法及代碼示例
- Python skimage.morphology.label用法及代碼示例
- Python skimage.morphology.max_tree_local_maxima用法及代碼示例
- Python skimage.morphology.flood用法及代碼示例
- Python skimage.morphology.diameter_closing用法及代碼示例
- Python skimage.morphology.remove_small_objects用法及代碼示例
- Python skimage.morphology.reconstruction用法及代碼示例
- Python skimage.morphology.erosion用法及代碼示例
- Python skimage.morphology.diameter_opening用法及代碼示例
- Python skimage.morphology.max_tree用法及代碼示例
- Python skimage.morphology.local_minima用法及代碼示例
- Python skimage.morphology.medial_axis用法及代碼示例
- Python skimage.morphology.skeletonize用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.morphology.thin。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。