python - Matplotlib 输出图像质量

标签 python matplotlib

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

转换前:

enter image description here

转换后:

enter image description here

我试过:

plt.imshow(img2, cmap = 'gray')
plt.plot(aa = True)
plt.show()

激活抗锯齿功能,但似乎没有任何改变。有没有办法让第二张图片再次像第一张一样漂亮?

最佳答案

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

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

产生完全相同的图像。

关于python - Matplotlib 输出图像质量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51991592/

相关文章:

python - 如果共享单元格值则合并行

python - 检查IP是否在Python中的CIDR范围内

python - 多个标签掩码上的 Numpy,矢量化函数

python - 限制输入到SQLite3的字符数

python - 自定义 matplotlib 的配色方案

python - PyQt5 - 如何将关闭键(红色 x)连接到函数

python - Matplotlib,所有子图的一个颜色条,覆盖在纸张大小上

python - 在 matplotlib 中用颜色填充 shapefile 多边形

Python 3 使用 Matplotlib 添加颜色条

python - 如何在 matplotlib 中美观地显示通用数量的轴?