ncut

ncut

skimage.future.graph.ncut(labels, rag, thresh=0.001, num_cuts=10, in_place=True, max_edge=1.0) [source]

Perform Normalized Graph cut on the Region Adjacency Graph.

Given an image’s labels and its similarity RAG, recursively perform a 2-way normalized cut on it. All nodes belonging to a subgraph that cannot be cut further are assigned a unique label in the output.

Parameters:

labels : ndarray

The array of labels.

rag : RAG

The region adjacency graph.

thresh : float

The threshold. A subgraph won’t be further subdivided if the value of the N-cut exceeds thresh.

num_cuts : int

The number or N-cuts to perform before determining the optimal one.

in_place : bool

If set, modifies rag in place. For each node n the function will set a new attribute rag.node[n]['ncut label'].

max_edge : float, optional

The maximum possible value of an edge in the RAG. This corresponds to an edge between identical regions. This is used to put self edges in the RAG.

Returns:

out : ndarray

The new labeled array.

References

[R225] 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.

Examples

>>> from skimage import data, segmentation
>>> from skimage.future import graph
>>> img = data.astronaut()
>>> labels = segmentation.slic(img, compactness=30, n_segments=400)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
>>> new_labels = graph.cut_normalized(labels, rag)
doc_scikit_image
2017-01-12 17:22:32
Comments
Leave a Comment

Please login to continue.