python-imaging-library - python PIL图像打开不是RGB

标签 python-imaging-library

我一直在尝试使用打开 .jpg 图像

im = Image.open('file.jpg').

我的问题是,由于某种原因,“im”不是 RGB 图像,即 channel 不是 R、G、B。这也会导致 im.convert('L') (rgb2gray) 给出了一个非常糟糕的结果。

channel 0 image ,
attemped gray sacale .

我正在使用:Python 2.7.12 |Anaconda 4.1.1(64 位)

我非常感谢任何帮助解决这个问题。

编辑 :
似乎问题在于 matplotlib 颜色图设置不正确。有谁知道为什么?以及如何解决?

最佳答案

您可以在 im.mode 中找到当前模式并使用 im.convert('RGB') 进行转换.

关于python-imaging-library - python PIL图像打开不是RGB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39111106/

相关文章:

django - 图片上传在网络上损坏,但 PIL 在 django shell 中运行良好

python - AttributeError : module 'scipy.misc' has no attribute 'imread'

python - 无法安装 PIL

python - PIL 中的 PNG 图像质量

python - 使用 Python 进行分形图像缩放

python - Tkinter Canvas 闪烁

python - Python中将图片分成矩形信息

python - PIL zip jpeg 解码器在运行时不工作,但在安装/自测试时工作

python - 在 python 中屏蔽然后粘贴两个图像

image-processing - 有什么比 ImageMagick 更快的吗?