test_imageutil.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:nuts-ml 作者: maet3608 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号