admin管理员组文章数量:1565292
matplotlib.pyplot
透视变换
import math
import matplotlib.pyplot as plt
from PIL import Image
if __name__ == '__main__':
img = Image.open('./example.png').resize((128, 128))
params = [
[0.5, 0.0, -64, 0.0, 1.0, -64, 0.0, 0.0],
[1.5, 0.0, -64, 0.0, 1.0, -64, 0.0, 0.0],
[1.0, 0.0, -64, 0.0, 0.5, -64, 0.0, 0.0],
[1.0, 0.0, -64, 0.0, 1.5, -64, 0.0, 0.0],
[1.0, 0.5, -64, 0.0, 1.0, -64, 0.0, 0.0],
[1.0, -.5, -64, 0.0, 1.0, -64, 0.0, 0.0],
[1.0, 0.0, -64, 0.5, 1.0, -64, 0.0, 0.0],
[1.0, 0.0, -64, -.5, 1.0, -64, 0.0, 0.0],
[1.0, 0.0, -32, 0.0, 1.0, -64, 0.0, 0.0],
[1.0, 0.0, -64, 0.0, 1.0, -32, 0.0, 0.0],
[1.0, 0.0, -64, 0.0, 1.0, -64, 0.001, 0.0],
[1.0, 0.0, -64, 0.0, 1.0, -64, -0.001, 0.0],
[1.0, 0.0, -64, 0.0, 1.0, -64, 0.0, 0.001],
[1.0, 0.0, -64, 0.0, 1.0, -64, 0.0, -0.001],
[1.0, 0.0, -64, 0.0, 1.0, -64, 0.0, 0.0],
]
plt.rcParams['figure.figsize'] = (16.0, 8.0)
row, col = math.ceil(len(params)/5), 5
plt.subplots(row, col, constrained_layout=True)
for i in range(len(params)):
plt.subplot(row, col, i+1)
plt.imshow(img.transform((256, 256), Image.PERSPECTIVE, params[i]))
plt.title(
'['+(', '.join(['%.3f' % e for e in params[i]]))+']',
fontsize=7
)
plt.show()
本文标签: 透视pyplotmatplotlibImageperspective
版权声明:本文标题:matplotlib.pyplot 透视变换 Image.PERSPECTIVE 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1725894575a1047475.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论