skimage2.graph.merge_hierarchical#
- skimage2.graph.merge_hierarchical(labels, rag, thresh, rag_copy, in_place_merge, merge_func, weight_func)[source]#
Perform hierarchical merging of a RAG.
Greedily merges the most similar pair of nodes until no edges lower than
threshremain.- Parameters:
- labelsndarray
The array of labels.
- ragRAG
The Region Adjacency Graph.
- threshfloat
Regions connected by an edge with weight smaller than
threshare merged.- rag_copybool
If set, the RAG copied before modifying.
- in_place_mergebool
If set, the nodes are merged in place. Otherwise, a new node is created for each merge..
- merge_funccallable
This function is called before merging two nodes. For the RAG
graphwhile mergingsrcanddst, it is called as followsmerge_func(graph, src, dst).- weight_funccallable
The function to compute the new weights of the nodes adjacent to the merged node. This is directly supplied as the argument
weight_functomerge_nodes.
- Returns:
- outndarray
The new labeled array.