def test_pad_input():
 template = (0.5 * diamond(2))
 image = (0.5 * np.ones((9, 19)))
 mid = slice(2, 7)
 image[mid, :3] -= template[:, (-3):]
 image[mid, 4:9] += template
 image[mid, (-9):(-4)] -= template
 image[mid, (-3):] += template[:, :3]
 result = match_template(image, template, pad_input=True, constant_values=image.mean())
 sorted_result = np.argsort(result.flat)
 (i, j) = np.unravel_index(sorted_result[:2], result.shape)
 assert_equal(j, (12, 0))
 (i, j) = np.unravel_index(sorted_result[(-2):], result.shape)
 assert_equal(j, (18, 6))

def test_pad_input ( ) : template = ( 0.5 * diamond ( 2 ) ) image = ( 0.5 * np . ones ( ( 9 , 19 ) ) ) mid = slice ( 2 , 7 ) image [ mid , : 3 ] -= template [ : , ( - 3 ) : ] image [ mid , 4 : 9 ] += template image [ mid , ( - 9 ) : ( - 4 ) ] -= template image [ mid , ( - 3 ) : ] += template [ : , : 3 ] result = match_template ( image , template , pad_input = True , constant_values = image . mean ( ) ) sorted_result = np . argsort ( result . flat ) ( i , j ) = np . unravel_index ( sorted_result [ : 2 ] , result . shape ) assert_equal ( j , ( 12 , 0 ) ) ( i , j ) = np . unravel_index ( sorted_result [ ( - 2 ) : ] , result . shape ) assert_equal ( j , ( 18 , 6 ) )
test match_template when pad_input=true .