mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-08 11:26:12 +08:00
Add tests for generic RAG construction
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user