{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / graph / _graph_cut / cut_normalized

function

skimage.graph._graph_cut:cut_normalized

source: /dev/scikit-image/src/skimage/graph/_graph_cut.py :71

Signature

def   cut_normalized ( labels rag thresh = 0.001 num_cuts = 10 in_place = True max_edge = 1.0 * rng = None )

Summary

Perform Normalized Graph cut on the Region Adjacency Graph.

Extended Summary

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.nodes[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.

rng : {`numpy.random.Generator`, int}, optional

Pseudo-random number generator. By default, a PCG64 generator is used (see numpy.random.default_rng). If rng is an int, it is used to seed the generator.

The rng is used to determine the starting point of scipy.sparse.linalg.eigsh.

Returns

out : ndarray

The new labeled array.

Examples

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

Aliases

  • skimage.graph.cut_normalized