mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-01 12:37:29 +08:00
rebase and docstring changes
This commit is contained in:
@@ -4,9 +4,9 @@ RAG Merging
|
||||
===========
|
||||
|
||||
This example constructs a Region Adjacency Graph (RAG) and progressively merges
|
||||
regions which are similar in color. Merging two adjacent regions produces
|
||||
regions that are similar in color. Merging two adjacent regions produces
|
||||
a new regions with all the pixels from the merged regions. Regions are merged
|
||||
till no two adjacent regions are similar enough.
|
||||
until no highly similar regions remain.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
@@ -38,8 +38,9 @@ def merge_hierarchical(labels, rag, thresh):
|
||||
rag : RAG
|
||||
The Region Adjacency Graph.
|
||||
thresh : float
|
||||
The threshold. Nodes are merged until the minimum edge weight in the
|
||||
graph exceeds `thresh`.
|
||||
The threshold. Regions connected by an edges with smaller wegiht than
|
||||
`thresh` are merged. A high value of `thresh` would mean that a lot of
|
||||
regions are merged, and the output will contain fewer regions.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -71,11 +72,9 @@ def merge_hierarchical(labels, rag, thresh):
|
||||
|
||||
rag.merge_nodes(x, y, _hmerge)
|
||||
|
||||
count = 0
|
||||
arr = np.arange(labels.max() + 1)
|
||||
for n, d in rag.nodes_iter(data=True):
|
||||
for l in d['labels']:
|
||||
arr[l] = count
|
||||
count += 1
|
||||
for ix, (n, d) in enumerate(rag.nodes_iter(data=True)):
|
||||
for label in d['labels']:
|
||||
arr[label] = ix
|
||||
|
||||
return arr[labels]
|
||||
|
||||
Reference in New Issue
Block a user