mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-02 04:42:23 +08:00
Add test for pad_input = True.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import numpy as np
|
||||
from numpy.testing import assert_array_almost_equal as assert_close
|
||||
|
||||
from skimage.morphology import diamond
|
||||
from skimage.feature import match_template, peak_local_max
|
||||
|
||||
|
||||
@@ -91,6 +92,26 @@ def test_switched_arguments():
|
||||
np.testing.assert_raises(ValueError, match_template, template, image)
|
||||
|
||||
|
||||
def test_pad_input():
|
||||
template = 10.0 * diamond(2)
|
||||
|
||||
image = np.zeros((9, 19))
|
||||
mid = slice(2, 7)
|
||||
image[mid, :3] = -template[:, -3:] # half min template centered at 0
|
||||
image[mid, 4:9] = template # full max template centered at 6
|
||||
image[mid, -9:-4] = -template # full min template centered at 12
|
||||
image[mid, -3:] = template[:, :3] # half max template centered at 18
|
||||
|
||||
result = match_template(image, template, pad_input=True)
|
||||
|
||||
# get the max and min results.
|
||||
sorted_result = np.argsort(result.flat)
|
||||
i, j = np.unravel_index(sorted_result[:2], result.shape)
|
||||
assert_close(j, (12, 0))
|
||||
i, j = np.unravel_index(sorted_result[-2:], result.shape)
|
||||
assert_close(j, (18, 6))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from numpy import testing
|
||||
testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user