mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 19:48:43 +08:00
Improved test case
This commit is contained in:
@@ -61,8 +61,10 @@ img = data.coffee()
|
||||
labels = segmentation.slic(img, compactness=30, n_segments=400)
|
||||
g = graph.rag_mean_color(img, labels)
|
||||
|
||||
labels2 = graph.merge_hierarchical(labels, g, 40, False, True,
|
||||
merge_mean_color, _weight_mean_color)
|
||||
labels2 = graph.merge_hierarchical(labels, g, thresh=40, rag_copy=False,
|
||||
in_place_merge=True,
|
||||
merge_func=merge_mean_color,
|
||||
weight_func=_weight_mean_color)
|
||||
|
||||
g2 = graph.rag_mean_color(img, labels2)
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_rag_hierarchical():
|
||||
img = np.zeros((8, 8, 3), dtype='uint8')
|
||||
labels = np.zeros((8, 8), dtype='uint8')
|
||||
|
||||
img[:, :, :] = 30
|
||||
img[:, :, :] = 31
|
||||
labels[:, :] = 1
|
||||
|
||||
img[0:4, 0:4, :] = 10, 10, 10
|
||||
@@ -146,14 +146,18 @@ def test_rag_hierarchical():
|
||||
|
||||
g = graph.rag_mean_color(img, labels)
|
||||
g2 = g.copy()
|
||||
thresh = 17.3206 # just above 10*sqrt(3)
|
||||
thresh = 20 # more than 11*sqrt(3)
|
||||
|
||||
result = merge_hierarchical_mean_color(labels, g, thresh)
|
||||
assert len(np.unique(result)) == 2
|
||||
assert(np.all(result[0:4, 0:4] == result[0, 0]))
|
||||
assert(np.all(result[4:, 0:4] == result[4, 0]))
|
||||
assert(np.all(result[:, 4:] == result[-1, -1]))
|
||||
|
||||
result = merge_hierarchical_mean_color(labels, g2, thresh,
|
||||
in_place_merge=True)
|
||||
assert len(np.unique(result)) == 2
|
||||
assert(np.all(result[0:4, 0:4] == result[0, 0]))
|
||||
assert(np.all(result[4:, 0:4] == result[4, 0]))
|
||||
assert(np.all(result[:, 4:] == result[-1, -1]))
|
||||
|
||||
result = graph.cut_threshold(labels, g, thresh)
|
||||
assert len(np.unique(result)) == 1
|
||||
assert np.all(result == result[0, 0])
|
||||
|
||||
Reference in New Issue
Block a user