Docstring changes and typos

This commit is contained in:
Vighnesh Birodkar
2014-08-08 23:16:38 +05:30
parent 1fa7bced8d
commit 6d0bf723d7
5 changed files with 15 additions and 15 deletions
+3 -3
View File
@@ -19,10 +19,10 @@ def DW_matrices(graph):
Returns
-------
D : csc_matrix
The diagonal matrix of the graph. `D[i, i]` is the sum of weights of
The diagonal matrix of the graph. ``D[i, i]`` is the sum of weights of
all edges incident on `i`. All other enteries are `0`.
W : csc_matrix
The weight matrix of the graph. `W[i, j]` is the weight of the edge
The weight matrix of the graph. ``W[i, j]`` is the weight of the edge
joining `i` to `j`.
"""
# sparse.eighsh is most efficient with CSC-formatted input
@@ -62,7 +62,7 @@ def ncut_cost(cut, D, W):
# D has elements only along the diagonal, one per node, so we can directly
# index the data attribute with cut.
assoc_a = D.data[cut].sum()
assoc_b = D.data[np.logical_not(cut)].sum()
assoc_b = D.data[~cut].sum()
return (cut_cost / assoc_a) + (cut_cost / assoc_b)
+1 -1
View File
@@ -6,7 +6,7 @@ cimport numpy as cnp
import numpy as np
def argmin2(cnp.float64_t[:] array):
def argmin2(cnp.double_t[:] array):
"""Return the index of the 2nd smallest value in an array.
Parameters
+6 -6
View File
@@ -89,11 +89,11 @@ def cut_normalized(labels, rag, thresh=0.001, num_cuts=10):
Returns
-------
out : ndarray
The new labelled array.
The new labeled array.
Examples
--------
>>> from skimage import data, graph, segmentation, color, io
>>> from skimage import data, graph, segmentation
>>> img = data.lena()
>>> labels = segmentation.slic(img, compactness=30, n_segments=400)
>>> rag = graph.rag_mean_color(img, labels, mode='similarity')
@@ -103,7 +103,7 @@ def cut_normalized(labels, rag, thresh=0.001, num_cuts=10):
----------
.. [1] Shi, J.; Malik, J., "Normalized cuts and image segmentation",
Pattern Analysis and Machine Intelligence,
IEEE Transactions on , vol.22, no.8, pp.888,905, Aug 2000
IEEE Transactions on , vol.22, no.8, pp.888,905, August 2000
"""
map_array = np.arange(labels.max() + 1)
@@ -138,7 +138,7 @@ def partition_by_cut(cut, rag):
def get_min_ncut(ev, d, w, num_cuts):
"""Threshold an eigen vector evenly, to determine minimum ncut.
"""Threshold an eigenvector evenly, to determine minimum ncut.
Parameters
----------
@@ -174,7 +174,7 @@ def get_min_ncut(ev, d, w, num_cuts):
def _ncut_relabel(rag, thresh, num_cuts, map_array):
"""Perform Normalized Graph cut on the Region Adjacency Graph.
Recursively partition the graph into 2, untill further subdividing
Recursively partition the graph into 2, until further subdivision
yields a cut greather than `thresh` or such a cut cannot be computed.
For such a subgraph, indices to labels of all its nodes map to a single
unique value.
@@ -212,7 +212,7 @@ def _ncut_relabel(rag, thresh, num_cuts, map_array):
stop = True
if not stop:
# Pick second smalles eigen vector.
# Pick second smalles eigenvector.
# Refer Shi & Malik 2001, Section 3.2.3, Page 893
vals, vectors = np.real(vals), np.real(vectors)
index2 = _ncut_cy.argmin2(vals)
+4 -4
View File
@@ -146,17 +146,17 @@ def rag_mean_color(image, labels, connectivity=2, mode='dissimilarity',
The strategy to assign edge weights.
'similarity' : The weight between two adjacent regions is the
:math:`|c_1 - c_2|`, where :math:`c1` and :math:`c2` are the mean
:math:`|c_1 - c_2|`, where :math:`c_1` and :math:`c_2` are the mean
colors of the two regions. It represents how different two regions
are.
'dissimilarity' : The weight between two adjacent is
:math:`e^{-d^2/sigma}` where :math:`d=|c_1 - c_2|`, where
:math:`c1` and :math:`c2` are the mean colors of the two regions.
:math:`c_1` and :math:`c_2` are the mean colors of the two regions.
It represents how similar two regions are.
sigma : float, optional
Used for computation when `mode='dissimilarity'`. It governs how close
to each other two colors should be, for their corresponding edge
Used for computation when `mode` is "dissimilarity". It governs how
close to each other two colors should be, for their corresponding edge
weight to be significant. A very large value of `sigma` could make
any two colors behave as though they were similar.
+1 -1
View File
@@ -95,4 +95,4 @@ def test_cut_normalized():
def test_rag_error():
img = np.zeros((10, 10, 3), dtype='uint8')
labels = np.zeros((10, 10), dtype='uint8')
testing.assert_raises(ValueError, graph.rag_mean_color,img, labels, 2, 'non existant mode')
testing.assert_raises(ValueError, graph.rag_mean_color, img, labels, 2, 'non existant mode')