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)
评论列表
文章目录