mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-07 19:25:49 +08:00
Merge pull request #276 from tonysyu/reconstruction-fix
BUG: Fix division error for Python 3 in reconstruction
This commit is contained in:
@@ -133,7 +133,7 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
|
||||
if offset == None:
|
||||
if not all([d % 2 == 1 for d in selem.shape]):
|
||||
ValueError("Footprint dimensions must all be odd")
|
||||
offset = np.array([d / 2 for d in selem.shape])
|
||||
offset = np.array([d // 2 for d in selem.shape])
|
||||
# Cross out the center of the selem
|
||||
selem[[slice(d, d + 1) for d in offset]] = False
|
||||
|
||||
|
||||
@@ -15,19 +15,19 @@ from skimage.morphology.greyreconstruct import reconstruction
|
||||
|
||||
def test_zeros():
|
||||
"""Test reconstruction with image and mask of zeros"""
|
||||
assert np.all(reconstruction(np.zeros((5, 7)), np.zeros((5, 7))) == 0)
|
||||
assert_close(reconstruction(np.zeros((5, 7)), np.zeros((5, 7))), 0)
|
||||
|
||||
|
||||
def test_image_equals_mask():
|
||||
"""Test reconstruction where the image and mask are the same"""
|
||||
assert np.all(reconstruction(np.ones((7, 5)), np.ones((7, 5))) == 1)
|
||||
assert_close(reconstruction(np.ones((7, 5)), np.ones((7, 5))), 1)
|
||||
|
||||
|
||||
def test_image_less_than_mask():
|
||||
"""Test reconstruction where the image is uniform and less than mask"""
|
||||
image = np.ones((5, 5))
|
||||
mask = np.ones((5, 5)) * 2
|
||||
assert np.all(reconstruction(image, mask) == 1)
|
||||
assert_close(reconstruction(image, mask), 1)
|
||||
|
||||
|
||||
def test_one_image_peak():
|
||||
@@ -35,7 +35,7 @@ def test_one_image_peak():
|
||||
image = np.ones((5, 5))
|
||||
image[2, 2] = 2
|
||||
mask = np.ones((5, 5)) * 3
|
||||
assert np.all(reconstruction(image, mask) == 2)
|
||||
assert_close(reconstruction(image, mask), 2)
|
||||
|
||||
|
||||
def test_two_image_peaks():
|
||||
@@ -60,13 +60,13 @@ def test_two_image_peaks():
|
||||
[1, 1, 1, 1, 1, 3, 3, 3],
|
||||
[1, 1, 1, 1, 1, 3, 3, 3],
|
||||
[1, 1, 1, 1, 1, 3, 3, 3]])
|
||||
assert np.all(reconstruction(image, mask) == expected)
|
||||
assert_close(reconstruction(image, mask), expected)
|
||||
|
||||
|
||||
def test_zero_image_one_mask():
|
||||
"""Test reconstruction with an image of all zeros and a mask that's not"""
|
||||
result = reconstruction(np.zeros((10, 10)), np.ones((10, 10)))
|
||||
assert np.all(result == 0)
|
||||
assert_close(result, 0)
|
||||
|
||||
|
||||
def test_fill_hole():
|
||||
|
||||
Reference in New Issue
Block a user