當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.morphology.area_closing用法及代碼示例

用法:

skimage.morphology.area_closing(image, area_threshold=64, connectivity=1, parent=None, tree_traverser=None)

執行圖像的區域關閉。

區域閉合會移除表麵小於 area_threshold 的圖像的所有暗結構。對於每個像素,輸出圖像都大於或等於輸入圖像,並且所有局部最小值都至少具有 area_threshold 個像素的表麵。

區域閉合類似於形態閉合,但它們不使用固定足跡,而是使用可變形的足跡,表麵 = area_threshold。

在二進製情況下,區域關閉等價於remove_small_holes;因此,該算子擴展到灰度圖像。

從技術上講,此運算符基於圖像的max-tree 表示。

參數

imagendarray

要計算area_closing 的輸入圖像。此圖像可以是任何類型。

area_threshold無符號int

尺寸參數(像素數)。默認值任意選擇為 64。

connectivity無符號 int 可選

鄰裏連通性。整數表示到達鄰居的最大正交步數。在 2D 中,4 鄰域為 1,8 鄰域為 2。默認值為 1。

parentndarray,int64,可選

表示倒置圖像的最大樹的父圖像。每個像素的值是其父級在 raveled 數組中的索引。有關詳細信息,請參閱注釋。

tree_traverser一維數組,int64,可選

有序像素索引(指的是散列數組)。像素被排序,使得每個像素都位於其父級之前(除了沒有父級的根)。

返回

outputndarray

與輸入圖像具有相同形狀和類型的輸出圖像。

注意

如果給函數一個max-tree表示(parent和tree_traverser),它們必須從這個函數的倒置圖像中計算出來,即:>>> P, S = max_tree(invert(f)) > >> 關閉 = diameter_closing(f, 3, parent=P, tree_traverser=S)

參考

1

Vincent L., Proc. “Grayscale area openings and closings, their efficient implementation and applications”, EURASIP Workshop on Mathematical Morphology and its Applications to Signal Processing, Barcelona, Spain, pp.22-27, May 1993.

2

Soille, P., “Morphological Image Analysis: Principles and Applications” (Chapter 6), 2nd edition (2003), ISBN 3540429883. DOI:10.1007/978-3-662-05088-0

3

Salembier, P., Oliveras, A., & Garrido, L. (1998). Antiextensive Connected Operators for Image and Sequence Processing. IEEE Transactions on Image Processing, 7(4), 555-570. DOI:10.1109/83.663500

4

Najman, L., & Couprie, M. (2006). Building the component tree in quasi-linear time. IEEE Transactions on Image Processing, 15(11), 3531-3539. DOI:10.1109/TIP.2006.877518

5

Carlinet, E., & Geraud, T. (2014). A Comparative Review of Component Tree Computation Algorithms. IEEE Transactions on Image Processing, 23(9), 3885-3895. DOI:10.1109/TIP.2014.2336551

例子

我們創建一個圖像(二次函數,中心有一個最小值,另外還有 4 個局部最小值。

>>> w = 12
>>> x, y = np.mgrid[0:w,0:w]
>>> f = 180 + 0.2*((x - w/2)**2 + (y-w/2)**2)
>>> f[2:3,1:5] = 160; f[2:4,9:11] = 140; f[9:11,2:4] = 120
>>> f[9:10,9:11] = 100; f[10,10] = 100
>>> f = f.astype(int)

我們可以計算閉合麵積:

>>> closed = area_closing(f, 8, connectivity=1)

所有小的最小值都被刪除,剩下的最小值至少為 8。

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.morphology.area_closing。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。