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


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

用法:

skimage.morphology.max_tree_local_maxima(image, connectivity=1, parent=None, tree_traverser=None)

確定圖像的所有局部最大值。

局部最大值被定義為具有相等灰度級的連接的像素集,其灰度級嚴格大於該集的直接鄰域中所有像素的灰度級。該函數標記局部最大值。

從技術上講,該實現基於圖像的max-tree 表示。如果已經計算了max-tree 表示,則該函數非常有效。否則,最好使用函數local_maxima。

參數

imagendarray

要計算最大值的輸入圖像。

connectivity無符號 int 可選

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

parentndarray,int64,可選

每個像素的值是其父級在 raveled 數組中的索引。

tree_traverser一維數組,int64,可選

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

返回

local_maxndarray,uint64

圖像的標記局部最大值。

參考

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 = 10
>>> x, y = np.mgrid[0:w,0:w]
>>> f = 20 - 0.2*((x - w/2)**2 + (y-w/2)**2)
>>> f[2:4,2:4] = 40; f[2:4,7:9] = 60; f[7:9,2:4] = 80; f[7:9,7:9] = 100
>>> f = f.astype(int)

我們可以計算所有局部最大值:

>>> maxima = max_tree_local_maxima(f)

生成的圖像包含標記的局部最大值。

相關用法


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