【发布时间】:2015-07-14 08:40:47
【问题描述】:
如何旋转图像文件并在 matplotlib 中绘制?
我知道我可以使用 PIL 打开它并旋转它,但这对于这个简单的功能来说似乎太过分了,我可能找不到。
我在这里找到了这段代码,但似乎不起作用:
from matplotlib import pyplot, image, transforms
img = image.imread('filename.png')
pyplot.ion()
fig = pyplot.figure()
ax = fig.add_subplot(111)
for degree in range(360):
pyplot.clf()
tr = transforms.Affine2D().rotate_deg(degree)
ax.imshow(img, transform=tr)
fig.canvas.draw()
【问题讨论】:
标签: python image matplotlib