fix region merging

correct variable names

add test for felzenszwalb's region merging
This commit is contained in:
mljli
2016-06-22 13:34:24 +08:00
parent 2cef2a9b25
commit 7ee54affab
2 changed files with 19 additions and 6 deletions
@@ -7,7 +7,7 @@ from skimage import data
@test_parallel()
def test_grey():
# very weak tests. This algorithm is pretty unstable.
# very weak tests.
img = np.zeros((20, 21))
img[:10, 10:] = 0.2
img[10:, :10] = 0.4
@@ -38,7 +38,7 @@ def test_minsize():
def test_color():
# very weak tests. This algorithm is pretty unstable.
# very weak tests.
img = np.zeros((20, 21, 3))
img[:10, :10, 0] = 1
img[10:, :10, 1] = 1
@@ -52,6 +52,17 @@ def test_color():
assert_array_equal(seg[10:, 10:], 3)
def test_merging():
# test region merging in the post-processing step
img = np.array([[0, 0.3], [0.7, 1]])
# With scale=0, only the post-processing is performed.
seg = felzenszwalb(img, scale=0, sigma=0, min_size=2)
# we expect 2 segments:
assert_equal(len(np.unique(seg)), 2)
assert_array_equal(seg[0, :], 0)
assert_array_equal(seg[1, :], 1)
if __name__ == '__main__':
from numpy import testing
testing.run_module_suite()