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: ndarrayThe array of labels.
rag: RAGThe region adjacency graph.
thresh: floatThe threshold. A subgraph won't be further subdivided if the value of the N-cut exceeds
thresh.num_cuts: intThe number or N-cuts to perform before determining the optimal one.
in_place: boolIf set, modifies
ragin place. For each nodenthe function will set a new attributerag.nodes[n]['ncut label'].max_edge: float, optionalThe 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}, optionalPseudo-random number generator. By default, a PCG64 generator is used (see numpy.random.default_rng). If
rngis an int, it is used to seed the generator.The
rngis used to determine the starting point of scipy.sparse.linalg.eigsh.
Returns
out: ndarrayThe 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