test_imageutil.py 文件源码

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

项目:nuts-ml 作者: maet3608 项目源码 文件源码
def test_load_image(datadirs):
    h, w = 213, 320
    _, formatsdir, arraydir, _ = datadirs
    pathpattern = formatsdir + '*'

    for filepath in glob(pathpattern):
        img = ni.load_image(filepath)
        is_color = 'color' in filepath
        assert img.shape == (h, w, 3) if is_color else (h, w)
        assert isinstance(img, np.ndarray)
        assert img.dtype == np.uint8
        assert np.max(img) <= 255
        assert np.min(img) >= 0

    for filepath in glob(pathpattern):
        img = ni.load_image(filepath, as_grey=True)
        assert img.shape == (h, w)
        assert np.max(img) <= 255
        assert np.min(img) >= 0

    for filepath in glob(pathpattern):
        img = ni.load_image(filepath)
        fdir, fname = op.split(filepath)
        arr = np.load(arraydir + fname + '.npy')
        nt.assert_allclose(img, arr)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号