def test_patch_iter():
img = np.reshape(np.arange(12), (3, 4))
patches = list(ni.patch_iter(img, (2, 2), 2))
expected = [np.array([[0, 1], [4, 5]]),
np.array([[2, 3], [6, 7]])]
for p, e in zip(patches, expected):
nt.assert_allclose(p, e)
patches = list(ni.patch_iter(img, (2, 2), 3))
expected = [np.array([[0, 1], [4, 5]])]
for p, e in zip(patches, expected):
nt.assert_allclose(p, e)
patches = list(ni.patch_iter(img, (1, 3), 1))
expected = [np.array([[0, 1, 2]]), np.array([[1, 2, 3]]),
np.array([[4, 5, 6]]), np.array([[5, 6, 7]]),
np.array([[8, 9, 10]]), np.array([[9, 10, 11]])]
for p, e in zip(patches, expected):
nt.assert_allclose(p, e)
评论列表
文章目录