rebase and docstring changes

This commit is contained in:
Vighnesh Birodkar
2014-08-15 15:00:58 +05:30
parent 9a192bf1cb
commit a080aa724a
2 changed files with 8 additions and 9 deletions
+2 -2
View File
@@ -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.
"""
+6 -7
View File
@@ -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]