mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-11 08:17:09 +08:00
Refer sections of paper in comments
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from .spath import shortest_path
|
||||
from .mcp import MCP, MCP_Geometric, MCP_Connect, MCP_Flexible, route_through_array
|
||||
from .rag import rag_mean_color, RAG
|
||||
from .graph_cut import cut_threshold, cut_n
|
||||
from .graph_cut import cut_threshold, cut_normalized
|
||||
|
||||
__all__ = ['shortest_path',
|
||||
'MCP',
|
||||
@@ -11,5 +11,5 @@ __all__ = ['shortest_path',
|
||||
'route_through_array',
|
||||
'rag_mean_color',
|
||||
'cut_threshold',
|
||||
'cut_n',
|
||||
'cut_normalized',
|
||||
'RAG']
|
||||
|
||||
@@ -145,6 +145,7 @@ def _ncut_relabel(rag, thresh, num_cuts, map_array):
|
||||
d2.data = 1.0/d2.data
|
||||
# the square root
|
||||
d2.data = np.sqrt(d2.data)
|
||||
# Refer to Equation 7
|
||||
vals, vectors = linalg.eigsh(d2*(d - w)*d2, which='SM',
|
||||
k=min(100, m - 2))
|
||||
except ValueError:
|
||||
@@ -152,6 +153,7 @@ def _ncut_relabel(rag, thresh, num_cuts, map_array):
|
||||
error = True
|
||||
|
||||
if not error:
|
||||
# Refer Section 3.2.3
|
||||
vals, vectors = np.real(vals), np.real(vectors)
|
||||
index2 = _ncut_cy.argmin2(vals)
|
||||
|
||||
@@ -160,6 +162,7 @@ def _ncut_relabel(rag, thresh, num_cuts, map_array):
|
||||
|
||||
mcut = np.inf
|
||||
threshold = None
|
||||
# Refer Section 3.1.3
|
||||
# Perform evenly spaced n-cuts and determine the optimal one.
|
||||
for t in np.linspace(0, 1, num_cuts, endpoint=False):
|
||||
mask = ev > t
|
||||
@@ -178,6 +181,7 @@ def _ncut_relabel(rag, thresh, num_cuts, map_array):
|
||||
sub1 = rag.subgraph(nodes1)
|
||||
sub2 = rag.subgraph(nodes2)
|
||||
|
||||
# Refer Section 3.2.5
|
||||
_ncut_relabel(sub1, thresh, num_cuts, map_array)
|
||||
_ncut_relabel(sub2, thresh, num_cuts, map_array)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user