skimage2.graph.cut_threshold#
- skimage2.graph.cut_threshold(labels, rag, thresh, in_place=True)[source]#
Combine regions separated by weight less than threshold.
Given an imageâs labels and its RAG, output new labels by combining regions whose nodes are separated by a weight less than the given threshold.
- Parameters:
- labelsndarray
The array of labels.
- ragRAG
The region adjacency graph.
- threshfloat
The threshold. Regions connected by edges with smaller weights are combined.
- in_placebool
If set, modifies
ragin place. The function will remove the edges with weights less thatthresh. If set toFalsethe function makes a copy ofragbefore proceeding.
- Returns:
- outndarray
The new labelled array.
References
[1]Alain Tremeau and Philippe Colantoni âRegions Adjacency Graph Applied To Color Image Segmentationâ DOI:10.1109/83.841950
Examples
>>> from _skimage2 import data, segmentation, graph >>> img = data.astronaut() >>> labels = segmentation.slic(img) >>> rag = graph.rag_mean_color(img, labels) >>> new_labels = graph.cut_threshold(labels, rag, 10)