【发布时间】:2020-04-07 09:46:27
【问题描述】:
我继承了旧代码,由于 scipy 的更新,我现在必须将 scipy.misc.imresize 替换为 PIL.Image.resize。
这是原始代码
# xn.shape = (519, 20)
xnr = scipy.misc.imresize(xn, (200, xn.shape[1]))
# xnr.shape = (200, 20) i think ?
SomeOtherArray[i, :] = xnr.flatten()
按照here的建议,我应该打电话给np.array(Image.fromarray(arr).resize())
# xn.shape = (519, 20)
xnr = np.array(Image.fromarray(xn).resize((200, xn.shape[1])))
# xnr.shape = (20, 200) !!! Not (200, 20)
SomeOtherArray[i, :] = xnr.flatten()
问题1:xnr = scipy.misc.imresize(xn, (200, xn.shape[1])) 给出(200, 20) 的形状是否正确
问题 2:我如何使在使用 PIL 之后,xnr 是正确的,正如原始代码中先前所预期的那样?
【问题讨论】:
标签: python scipy python-imaging-library image-resizing resize-image