mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-27 11:27:08 +08:00
indentation correction
This commit is contained in:
committed by
Vighnesh Birodkar
parent
3cf6c8b1ce
commit
caba3041d1
@@ -8,7 +8,7 @@ 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 pyplot as plt, colors
|
||||
from matplotlib import pyplot as colors
|
||||
|
||||
img = data.coffee()
|
||||
gimg = color.rgb2gray(img)
|
||||
|
||||
@@ -349,8 +349,7 @@ def rag_boundary(labels, edge_map, connectivity=2):
|
||||
nbr_indices = list(np.ndindex(*[2]*labels.ndim))
|
||||
del nbr_indices[0]
|
||||
nbr_indices_arr = ([idx for idx in nbr_indices if np.linalg.norm(idx)
|
||||
<= connectivity])
|
||||
|
||||
<= connectivity])
|
||||
|
||||
iter_shape = tuple(np.array(labels.shape) - 1)
|
||||
|
||||
@@ -358,14 +357,14 @@ def rag_boundary(labels, edge_map, connectivity=2):
|
||||
|
||||
index_arr = np.array(index)
|
||||
current = labels[index]
|
||||
graph.add_node(current, {'labels':[current]})
|
||||
graph.add_node(current, {'labels': [current]})
|
||||
|
||||
for nbr_index in nbr_indices_arr:
|
||||
|
||||
adjacent_idx = tuple(index_arr + nbr_index)
|
||||
adjacent = labels[adjacent_idx]
|
||||
|
||||
if current==adjacent:
|
||||
if current == adjacent:
|
||||
continue
|
||||
|
||||
if graph.has_edge(current, adjacent):
|
||||
|
||||
@@ -202,8 +202,8 @@ def test_rag_boundary():
|
||||
labels = np.zeros((16, 16), dtype='uint8')
|
||||
edge_map = np.zeros_like(labels, dtype=float)
|
||||
|
||||
edge_map[8,:] = 0.5
|
||||
edge_map[:,8] = 1.0
|
||||
edge_map[8, :] = 0.5
|
||||
edge_map[:, 8] = 1.0
|
||||
|
||||
labels[:8, :8] = 1
|
||||
labels[:8, 8:] = 2
|
||||
|
||||
Reference in New Issue
Block a user