【发布时间】:2020-06-04 04:16:44
【问题描述】:
我有以下图片文件:
我使用 PIL 和 Skimage 打开它,但出现以下错误
首先使用 PIL(尝试使用和不使用 trucate 选项): 代码:
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
img = Image.open("image_output.pgm")
错误:
OSError: cannot identify image file 'image_output.pgm'
还有 Skimage:
代码:
from skimage import io
img = io.imread("image_output.pgm")
错误:
OSError: cannot identify image file <_io.BufferedReader name='image_output.pgm'>
我可以使用系统照片查看器和 Matlab 等 GUI 应用程序打开文件。
如何诊断图像有什么问题?我将字节数据与可以在 Python 中打开的其他 PGM 文件进行了比较,但无法识别差异。
谢谢。
【问题讨论】:
-
您的链接似乎无效 - 请检查一下。
-
另外,您没有显示打开它的代码。
-
@MarkSetchell 我已经修复了图片链接并添加了代码。请让我知道您是否可以下载图像。另外,如果您投票支持“关闭”,请重新考虑。
-
关闭投票不是来自我。下面回答:-)
标签: python-3.x python-imaging-library scikit-image pgm