mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-26 13:37:17 +08:00
Check that image is larger than template.
This commit is contained in:
@@ -33,6 +33,8 @@ def match_template(image, template, pad_output=True):
|
||||
beyond the image edges.
|
||||
|
||||
"""
|
||||
if np.any(np.less(image.shape, template.shape)):
|
||||
raise ValueError("Image must be larger than template.")
|
||||
image = _convert(image, np.float32)
|
||||
template = _convert(template, np.float32)
|
||||
|
||||
|
||||
@@ -70,6 +70,12 @@ def test_normalization():
|
||||
assert np.allclose(result.flat[iflat_max], 1)
|
||||
|
||||
|
||||
def test_switched_arguments():
|
||||
image = np.ones((5, 5))
|
||||
template = np.ones((3, 3))
|
||||
np.testing.assert_raises(ValueError, match_template, template, image)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from numpy import testing
|
||||
testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user