我试图使用PIL扭曲两个不同大小的图像;具体来说,通过将未来扭曲的目标图像的形状(大小)设置为numpy数组,我遇到了AttributeError:
文件“C:\ Anaconda2 \ lib \ site-packages \ PIL \ Image.py”,第632行, getattr 引发AttributeError(名称) AttributeError:shape
为什么会这样?我的印象是我前段时间正在做这件事并且工作得很好,更不用说我绝对不明白python不理解的是什么(形状属性应该采取这是一个没有问题的输入)
import skimage.io
from PIL import Image
import numpy as np
Img1 = Image.open(picture1 + ".png")
Img1
Img2 = Image.open(picture2 + ".png")
Img2
r, c = Img2.shape[:2]
# creates array for the future shape in x,y
corners = np.array([[0, 0],
[0, r],
[c, 0],
[c, r]])
...
问候,JJ
答案 0 :(得分:1)
我认为Image对象具有 size 属性,而数组具有 shape 属性。尝试在代码中重命名它。 (见:http://effbot.org/imagingbook/image.htm)