Skip to content

Commit

Permalink
Correct expectation for test_offset_not_none
Browse files Browse the repository at this point in the history
See bug report here: scikit-image/scikit-image#7315
  • Loading branch information
dchaley committed Feb 13, 2024
1 parent 56fac85 commit 51ea955
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion benchmarking/h_maxima/test_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
from numpy.testing import assert_array_almost_equal

from skimage._shared.utils import _supported_float_type
import skimage.morphology.grayreconstruct

# from skimage.morphology.grayreconstruct import reconstruction
from benchmark_utils import opencv_reconstruct
from fast_reconstruct_wrapper import cython_reconstruct_wrapper as reconstruction

xfail = pytest.mark.xfail
Expand Down Expand Up @@ -241,7 +243,7 @@ def test_offset_not_none():
"""Test reconstruction with valid offset parameter"""
seed = np.array([[0, 3, 6, 2, 1, 1, 1, 4, 2, 0]])
mask = np.array([[0, 8, 6, 8, 8, 8, 8, 4, 4, 0]])
expected = np.array([[0, 3, 6, 6, 6, 6, 6, 4, 4, 0]])
expected = np.array([[0, 6, 6, 4, 4, 4, 4, 4, 2, 0]])

assert_array_almost_equal(
reconstruction(
Expand All @@ -253,3 +255,32 @@ def test_offset_not_none():
),
expected,
)


@xfail(reason="scikit bug? https://github.com/scikit-image/scikit-image/issues/7315")
def test_offset_not_none_vs_opencv():
"""Test reconstruction with valid offset parameter"""
seed = np.array([0, 3, 6, 2, 1, 1, 1, 4, 2, 0])
mask = np.array([0, 8, 6, 8, 8, 8, 8, 4, 4, 0])
expected = np.array([0, 6, 6, 4, 4, 4, 4, 4, 2, 0])

footprint = np.array([1, 1, 1])

opencv_result = opencv_reconstruct(
seed.astype(np.uint8, copy=True),
mask.astype(np.uint8, copy=True),
footprint,
(0, 0),
)
assert_array_almost_equal(opencv_result, expected)

# This actually fails, it wants a different kind of offset
# but [[0], [0]] doesn't work nor does [0, 0] nor [[0, 0]]
scikit_result = skimage.morphology.grayreconstruct.reconstruction(
seed,
mask,
method="dilation",
footprint=np.array([[1, 1, 1]], dtype=np.uint8),
offset=np.array([[0], [0]], dtype=np.uint8),
)
assert_array_almost_equal(scikit_result, expected)

0 comments on commit 51ea955

Please sign in to comment.