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


Python skimage.future.graph.ncut用法及代碼示例

用法:

skimage.future.graph.ncut(labels, rag, thresh=0.001, num_cuts=10, in_place=True, max_edge=1.0, *, random_state=None)

對 Region Adjacency Graph 執行 Normalized Graph cut。

給定圖像的標簽及其相似性 RAG,遞歸地對其執行 2-way normalized cut。屬於不能被進一步切割的子圖的所有節點在輸出中被分配一個唯一的標簽。

參數

labelsndarray

標簽數組。

ragRAG

區域鄰接圖。

thresh浮點數

門檻。如果N-cut的值超過閾值,則不會進一步細分子圖。

num_cutsint

在確定最佳值之前要執行的編號或N-cuts。

in_placebool

如果設置,修改rag到位。對於每個節點n該函數將設置一個新屬性rag.nodes[n]['ncut label'].

max_edge浮點數,可選

RAG 中邊的最大可能值。這對應於相同區域之間的邊。這用於將自身邊放入 RAG。

random_state{無,int numpy.random.Generator },可選

如果random_state是沒有的numpy.random.Generator使用單例。如果random_state是一個int 一個新的Generator使用實例,播種random_state.如果random_state已經是一個Generator實例然後使用該實例。

random_state用於起點scipy.sparse.linalg.eigsh.

返回

outndarray

新標記的數組。

參考

1

Shi, J.; Malik, J., “Normalized cuts and image segmentation”, Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. 22, no. 8, pp. 888-905, August 2000.

例子

>>> from skimage import data, segmentation
>>> from skimage.future import graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
>>> new_labels = graph.cut_normalized(labels, rag)

相關用法


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