mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 17:47:05 +08:00
Added examples in docstring
This commit is contained in:
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user