Check that image is larger than template.

This commit is contained in:
Tony S Yu
2012-05-08 21:32:08 -04:00
parent 5e49eb4fb6
commit 0c1e3541b3
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -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)
+6
View File
@@ -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()