Matplotlib输出图像质量

时间:2018-08-23 17:50:35

标签: python matplotlib

将png图像转换为numpy数组并转换回png图像后,质量会降低。如果单击第二张图像,则可以看到它的完整尺寸。我认为问题在于查看转换后的图像时没有激活抗锯齿或其他过滤器。

转换前:

enter image description here

转换后:

enter image description here

我尝试过:

abcd1

激活抗锯齿,但似乎没有任何改变。有没有办法使第二张图像和第一张图像一样漂亮?

1 个答案:

答案 0 :(得分:0)

好吧,我想我找到了最简单的方法。

img1 = plt.imread(impath1, format = 'int32')
plt.imsave('test.png', img1, cmap = 'gray')

产生完全相同的图像。