我正在尝试调整图像大小。为此,我正在使用 skimage 调整大小。为此,输入将是 3d numpy 图像数组。并且输出将再次是一个较小维度的 3d numpy 数组。downSample = []for i in range(len(rgb_val)): downSample.append(resize(rgb_val[i], (rgb_val[i].shape[0] / 16, rgb_val[i].shape[1] / 16), anti_aliasing=True))在这里, rgb_val 只不过是一个列表,其中包含我的数据集中的 3d numpy 图像数组。但是在执行这个循环时,它向我显示了以下错误。我应该怎么做才能解决以下错误?---------------------------------------------------------------------------AssertionError Traceback (most recent call last)~/anaconda3/lib/python3.7/site-packages/skimage/_shared/utils.py in safe_as_int(val, atol) 147 try:--> 148 np.testing.assert_allclose(mod, 0, atol=atol) 149 except AssertionError:~/anaconda3/lib/python3.7/site-packages/numpy/testing/_private/utils.py in assert_allclose(actual, desired, rtol, atol, equal_nan, err_msg, verbose) 1451 assert_array_compare(compare, actual, desired, err_msg=str(err_msg),-> 1452 verbose=verbose, header=header, equal_nan=equal_nan) 1453 ~/anaconda3/lib/python3.7/site-packages/numpy/testing/_private/utils.py in assert_array_compare(comparison, x, y, err_msg, verbose, header, precision, equal_nan, equal_inf) 788 names=('x', 'y'), precision=precision)--> 789 raise AssertionError(msg) 790 except ValueError:AssertionError: Not equal to tolerance rtol=1e-07, atol=0.001(mismatch 66.66666666666666%) x: array([0.25, 0.5 , 0. ]) y: array(0)During handling of the above exception, another exception occurred:ValueError Traceback (most recent call last)<ipython-input-27-754225493c2e> in <module> 1 for i in range(len(rgb_val)): 2 downSample.append(resize(rgb_val[i], ((rgb_val[i].shape[0]) / 16, (rgb_val[i].shape[1]) / 16),----> 3 anti_aliasing=True)) 4 5 # downSample.append(resize(i, i.shape[0]/4, i.shape[1]/4), anti_aliasing = True)
1 回答
明月笑刀无情
TA贡献1828条经验 获得超4个赞
rgb_val可能包含非int类型对象。
请尝试以下操作:
downSample = []
for i in range(len(rgb_val)):
downSample.append(resize(int(rgb_val[i]), (int(rgb_val[i].shape[0] / 16), int(rgb_val[i].shape[1] / 16)),
anti_aliasing=True))
添加回答
举报
0/150
提交
取消