Add tests for generic RAG construction

This commit is contained in:
Juan Nunez-Iglesias
2015-12-14 17:12:11 +11:00
parent e9c4c87519
commit d5819f664a
+18
View File
@@ -178,3 +178,21 @@ def test_ncut_stable_subgraph():
new_labels, _, _ = segmentation.relabel_sequential(new_labels)
assert new_labels.max() == 0
def test_generic_rag_2d():
labels = np.array([[1, 2], [3, 4]], dtype=np.uint8)
g = graph.RAG(labels)
assert g.has_edge(1, 2) and g.has_edge(2, 4) and not g.has_edge(1, 4)
h = graph.RAG(labels, connectivity=2)
assert h.has_edge(1, 2) and h.has_edge(1, 4) and h.has_edge(2, 3)
def test_generic_rag_3d():
labels = np.arange(8, dtype=np.uint8).reshape((2, 2, 2))
g = graph.RAG(labels)
assert g.has_edge(0, 1) and g.has_edge(1, 3) and not g.has_edge(0, 3)
h = graph.RAG(labels, connectivity=2)
assert h.has_edge(0, 1) and h.has_edge(0, 3) and not h.has_edge(0, 7)
k = graph.RAG(labels, connectivity=3)
assert k.has_edge(0, 1) and k.has_edge(1, 2) and k.has_edge(2, 5)