相关疑难解决方法(0)

Matplotlib将图像文件旋转X度

如何旋转图像文件并在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()
Run Code Online (Sandbox Code Playgroud)

python image matplotlib

4
推荐指数
3
解决办法
2万
查看次数

标签 统计

image ×1

matplotlib ×1

python ×1