用法:
skimage.measure.euler_number(image, connectivity=None)
計算二值圖像中的歐拉特性。
對於 2D 對象,歐拉數是對象數減去孔數。對於 3D 對象,歐拉數等於對象的數量加上孔的數量,再減去隧道或環路的數量。
- image: (N, M) ndarray or (N, M, D) ndarray.:
2D 或 3D 圖像。如果圖像不是二進製的,則所有嚴格大於零的值都被視為對象。
- connectivity:int 可選
將像素/體素視為鄰居的最大正交跳數。接受的值範圍從 1 到 input.ndim 如果
None
,則使用input.ndim
的完整連接。為 2D 圖像定義了 4 個或 8 個鄰域(分別為連接 1 和 2)。為 3D 圖像定義了 6 個或 26 個鄰域(分別為連接 1 和 3)。連接 2 未定義。
- euler_number:int
圖像中所有對象的集合的歐拉特征。
參數:
返回:
注意:
歐拉特征是一個整數,說明了輸入圖像中所有對象的集合的拓撲結構。如果對象是 4 連通的,那麽背景是 8 連通的,反之亦然。
歐拉特性的計算是基於離散空間中的積分幾何公式。在實踐中,構建一個鄰域配置,並為每個配置應用一個 LUT。使用的係數是 Ohser 等人的係數。
計算幾個連通性的歐拉特性會很有用。不同連通性的結果之間的較大相對差異表明圖像分辨率(相對於對象和孔的大小)太低。
參考:
- 1
S. Rivollier. Analyse d’image geometrique et morphometrique par diagrammes de forme et voisinages adaptatifs generaux. PhD thesis, 2010. Ecole Nationale Superieure des Mines de Saint-Etienne. https://tel.archives-ouvertes.fr/tel-00560838
- 2
Ohser J., Nagel W., Schladitz K. (2002) The Euler Number of Discretized Sets - On the Choice of Adjacency in Homogeneous Lattices. In: Mecke K., Stoyan D. (eds) Morphology of Condensed Matter. Lecture Notes in Physics, vol 600. Springer, Berlin, Heidelberg.
例子:
>>> import numpy as np >>> SAMPLE = np.zeros((100,100,100)); >>> SAMPLE[40:60, 40:60, 40:60]=1 >>> euler_number(SAMPLE) 1... >>> SAMPLE[45:55,45:55,45:55] = 0; >>> euler_number(SAMPLE) 2... >>> SAMPLE = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], ... [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], ... [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], ... [1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0], ... [0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1], ... [0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]]) >>> euler_number(SAMPLE) # doctest: 0 >>> euler_number(SAMPLE, connectivity=1) # doctest: 2
相關用法
- Python skimage.measure.ransac用法及代碼示例
- Python skimage.measure.profile_line用法及代碼示例
- Python skimage.measure.perimeter_crofton用法及代碼示例
- Python skimage.measure.moments_hu用法及代碼示例
- Python skimage.measure.moments_coords_central用法及代碼示例
- Python skimage.measure.LineModelND用法及代碼示例
- Python skimage.measure.block_reduce用法及代碼示例
- Python skimage.measure.moments用法及代碼示例
- Python skimage.measure.shannon_entropy用法及代碼示例
- Python skimage.measure.moments_normalized用法及代碼示例
- Python skimage.measure.perimeter用法及代碼示例
- Python skimage.measure.moments_central用法及代碼示例
- Python skimage.measure.EllipseModel用法及代碼示例
- Python skimage.measure.regionprops用法及代碼示例
- Python skimage.measure.find_contours用法及代碼示例
- Python skimage.measure.CircleModel用法及代碼示例
- Python skimage.measure.label用法及代碼示例
- Python skimage.measure.regionprops_table用法及代碼示例
- Python skimage.measure.moments_coords用法及代碼示例
- Python skimage.metrics.hausdorff_distance用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.measure.euler_number。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。