mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-15 11:25:53 +08:00
cleanup
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -9,5 +9,5 @@ __all__ = ['rag_mean_color',
|
||||
'ncut',
|
||||
'draw_rag',
|
||||
'merge_hierarchical',
|
||||
'rag_boundary'
|
||||
'rag_boundary',
|
||||
'RAG']
|
||||
|
||||
@@ -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]})
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user