diff --git a/skimage/graph/tests/test_rag.py b/skimage/graph/tests/test_rag.py index 35eb5c38..0d5fa2ab 100644 --- a/skimage/graph/tests/test_rag.py +++ b/skimage/graph/tests/test_rag.py @@ -100,7 +100,6 @@ def test_cut_normalized(): assert new_labels.max() == 1 -@skipif(not is_installed('networkx')) def test_rag_error(): img = np.zeros((10, 10, 3), dtype='uint8') labels = np.zeros((10, 10), dtype='uint8') @@ -108,3 +107,23 @@ def test_rag_error(): labels[5:, :] = 1 testing.assert_raises(ValueError, graph.rag_mean_color, img, labels, 2, 'non existant mode') + +@skipif(not is_installed('networkx')) +def test_merge_hierarchical(): + img = np.zeros((100, 100, 3), dtype='uint8') + img[:50, :50] = 255, 255, 255 + img[:50, 50:] = 254, 254, 254 + img[50:, :50] = 2, 2, 2 + img[50:, 50:] = 1, 1, 1 + + labels = np.zeros((100, 100), dtype='uint8') + labels[:50, :50] = 0 + labels[:50, 50:] = 1 + labels[50:, :50] = 2 + labels[50:, 50:] = 3 + + rag = graph.rag_mean_color(img, labels) + new_labels = graph.merge_hierarchical(labels, rag, 10) + + # Two labels + assert new_labels.max() == 1