diff --git a/doc/examples/plot_rag_boundary.py b/doc/examples/plot_rag_boundary.py index c975f884..5063d96a 100644 --- a/doc/examples/plot_rag_boundary.py +++ b/doc/examples/plot_rag_boundary.py @@ -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) diff --git a/skimage/future/graph/__init__.py b/skimage/future/graph/__init__.py index e73c8d19..d685a793 100644 --- a/skimage/future/graph/__init__.py +++ b/skimage/future/graph/__init__.py @@ -9,5 +9,5 @@ __all__ = ['rag_mean_color', 'ncut', 'draw_rag', 'merge_hierarchical', - 'rag_boundary' + 'rag_boundary', 'RAG'] diff --git a/skimage/future/graph/rag.py b/skimage/future/graph/rag.py index fc6e1d6f..566c7261 100644 --- a/skimage/future/graph/rag.py +++ b/skimage/future/graph/rag.py @@ -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]}) diff --git a/skimage/future/graph/tests/test_rag.py b/skimage/future/graph/tests/test_rag.py index 4af3d854..dafa0ddc 100644 --- a/skimage/future/graph/tests/test_rag.py +++ b/skimage/future/graph/tests/test_rag.py @@ -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 \ No newline at end of file + assert len(g.edges()) == 4