This commit is contained in:
Vighnesh Birodkar committed 2016-01-06 15:17:48 -05:00
1 parent e8f2805d64
commit 422dfc6c22
4 files changed
+5 -7

No files matched your search

-2
View File
@@ -8,8 +8,6 @@ This example demonstrates construction of region boundary based RAGs with the
"""
from skimage.future import graph
from skimage import data, segmentation, color, filters, io
from matplotlib import colors
import numpy as np
img = data.coffee()
gimg = color.rgb2gray(img)
+1 -1
View File
@@ -9,5 +9,5 @@ __all__ = ['rag_mean_color',
'ncut',
'draw_rag',
'merge_hierarchical',
'rag_boundary'
'rag_boundary',
'RAG']
+3 -3
View File
@@ -4,7 +4,7 @@ from numpy.lib.stride_tricks import as_strided
from scipy import ndimage as ndi
from scipy import sparse
import math
from ... import draw, measure, segmentation, util, color, morphology
from ... import draw, measure, segmentation, util, color
try:
from matplotlib import colors
from matplotlib import cm
@@ -364,10 +364,10 @@ def rag_boundary(labels, edge_map, connectivity=2):
graph_matrix = data_coo.tocsr()
graph_matrix.data /= count_matrix.data
rag = nx.Graph()
rag = RAG()
rows, cols = graph_matrix.nonzero()
graph_data = zip(rows, cols, graph_matrix.data)
rag.add_weighted_edges_from(graph_data)
rag.add_weighted_edges_from(graph_data, attr='weight')
for n in rag.nodes():
rag.node[n].update({'labels': [n]})
+1 -1
View File
@@ -212,4 +212,4 @@ def test_rag_boundary():
g = graph.rag_boundary(labels, edge_map, connectivity=1)
assert len(g.nodes()) == 4
assert len(g.edges()) == 4
assert len(g.edges()) == 4