mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-09 04:48:03 +08:00
Fix doctests
This commit is contained in:
+19
-19
@@ -60,33 +60,33 @@ def match_template(image, template, pad_input=False, mode='constant',
|
||||
>>> template = np.zeros((3, 3))
|
||||
>>> template[1, 1] = 1
|
||||
>>> template
|
||||
array([[ 0. 0. 0.]
|
||||
[ 0. 1. 0.]
|
||||
[ 0. 0. 0.]])
|
||||
array([[ 0., 0., 0.],
|
||||
[ 0., 1., 0.],
|
||||
[ 0., 0., 0.]])
|
||||
>>> image = np.zeros((6, 6))
|
||||
>>> image[1, 1] = 1
|
||||
>>> image[4, 4] = -1
|
||||
>>> image
|
||||
array([[ 0. 0. 0. 0. 0. 0.]
|
||||
[ 0. 1. 0. 0. 0. 0.]
|
||||
[ 0. 0. 0. 0. 0. 0.]
|
||||
[ 0. 0. 0. 0. 0. 0.]
|
||||
[ 0. 0. 0. 0. -1. 0.]
|
||||
[ 0. 0. 0. 0. 0. 0.]])
|
||||
array([[ 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 1., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0.],
|
||||
[ 0., 0., 0., 0., -1., 0.],
|
||||
[ 0., 0., 0., 0., 0., 0.]])
|
||||
>>> result = match_template(image, template)
|
||||
>>> np.round(result, 3)
|
||||
array([[ 1. -0.125 0. 0. ]
|
||||
[-0.125 -0.125 0. 0. ]
|
||||
[ 0. 0. 0.125 0.125]
|
||||
[ 0. 0. 0.125 -1. ]])
|
||||
array([[ 1. , -0.125, 0. , 0. ],
|
||||
[-0.125, -0.125, 0. , 0. ],
|
||||
[ 0. , 0. , 0.125, 0.125],
|
||||
[ 0. , 0. , 0.125, -1. ]])
|
||||
>>> result = match_template(image, template, pad_input=True)
|
||||
>>> np.round(result, 3)
|
||||
array([[-0.125 -0.125 -0.125 0. 0. 0. ]
|
||||
[-0.125 1. -0.125 0. 0. 0. ]
|
||||
[-0.125 -0.125 -0.125 0. 0. 0. ]
|
||||
[ 0. 0. 0. 0.125 0.125 0.125]
|
||||
[ 0. 0. 0. 0.125 -1. 0.125]
|
||||
[ 0. 0. 0. 0.125 0.125 0.125]])
|
||||
array([[-0.125, -0.125, -0.125, 0. , 0. , 0. ],
|
||||
[-0.125, 1. , -0.125, 0. , 0. , 0. ],
|
||||
[-0.125, -0.125, -0.125, 0. , 0. , 0. ],
|
||||
[ 0. , 0. , 0. , 0.125, 0.125, 0.125],
|
||||
[ 0. , 0. , 0. , 0.125, -1. , 0.125],
|
||||
[ 0. , 0. , 0. , 0.125, 0.125, 0.125]])
|
||||
"""
|
||||
|
||||
if np.any(np.less(image.shape, template.shape)):
|
||||
|
||||
Reference in New Issue
Block a user