python - Scipy imsave 使我的图像变暗

标签 python image python-2.7 numpy scipy

我正在进行图像处理,并在 Jupyter Notebook 中使用 Python 2.7。 但是,当我使用 scipy.misc.imsave() 将 numpy 数组保存为图像时,结果看起来比使用 matplotlib 可视化时更暗

这是我在笔记本中绘制图像时的结果:

import matplotlib.pyplot as plot    
plot.imshow(img)

enter image description here

这是我保存时的图像:

scipy.misc.imsave(img, 'img.png')

enter image description here

图像看起来比应有的颜色更暗,我不知道为什么。有人遇到过类似的问题吗?

最佳答案

这是因为 imsave() 在最小值和最大值之间标准化图像。

你可以这样做:

scipy.misc.toimage(img, cmin=0, cmax=255).save('img.png')

关于python - Scipy imsave 使我的图像变暗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46090757/

相关文章:

python - jupyter notebook - 检查魔法是否可用

python - 在 python 的 tkinter gui 中悬停在 Canvas 上绘制的线上运行事件

javascript - 在鼠标悬停时显示隐藏图像

python-2.7 - 两个矩阵之间的最短路径

python-2.7 - 如何使用pytest测试使用数据库连接的python函数?

python - 如何将多个 EPS 文件放置到 PDF 的单个页面上?

python - 为什么我的代码在编辑后运行速度不快?

javascript - 是否可以在通过表单上传之前预览本地镜像?

c# - Picture Box 图片来源是否可能?

python - 有没有办法在 Python 2.7 中找到字符的 Unicode 代码点?