Added examples in docstring

This commit is contained in:
Vighnesh Birodkar
2014-06-16 22:59:23 +05:30
parent 850f835114
commit 1ad8ad733b
2 changed files with 28 additions and 11 deletions
+9
View File
@@ -23,6 +23,15 @@ def threshold_cut(label, rag, thresh):
-------
out : (width, height, 3) or (width, height, depth, 3) ndarray
The new labelled array.
Examples
--------
>>> from skimage import data,graph,segmentation
>>> img = data.lena()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_meancolor(img, labels)
>>> new_labels = graph.threshold_cut(labels, rag, 10)
"""
to_remove = [(x, y)
for x, y, d in rag.edges_iter(data=True) if d['weight'] >= thresh]
+19 -11
View File
@@ -14,20 +14,20 @@ class RAG(nx.Graph):
"""
def merge_nodes(self, i, j):
"""Merges nodes `i` and `j`.
"""Merges nodes `i` and `j`.
The new combined node is adjacent to all the neighbors of `i`
and `j`. In case of conflicting edges, edge with higher weight
is chosen.
The new combined node is adjacent to all the neighbors of `i`
and `j`. In case of conflicting edges, edge with higher weight
is chosen.
Parameters
----------
i : int
Node to be merged.
j : int
Node to be merged.
Parameters
----------
i : int
Node to be merged.
j : int
Node to be merged.
"""
"""
if not self.has_edge(i, j):
raise ValueError('Cant merge non adjacent nodes')
@@ -69,6 +69,14 @@ def rag_meancolor(img, labels):
-------
out : RAG
The region adjacency graph.
Examples
--------
>>> from skimage import data,graph,segmentation
>>> img = data.lena()
>>> labels = segmentation.slic(img)
>>> rag = graph.rag_meancolor(img, labels)
"""
img = util.img_as_ubyte(img)