【发布时间】:2019-09-12 02:24:59
【问题描述】:
我正在尝试使用模块 skimage 在 python 中转换 .tif 图像。 它无法正常工作。
from skimage import io
img = io.imread('/content/IMG_0007_4.tif')
io.imsave('/content/img.jpg', img)
这是错误:
/usr/local/lib/python3.6/dist-packages/imageio/core/functions.py in get_writer(uri, format, mode, **kwargs)
if format is None:
raise ValueError(
"Could not find a format to write the specified file " "in mode %r" % mode)
ValueError: Could not find a format to write the specified file in mode 'i'
编辑 1:
我发现这样做的一种方法是使用 skimage 打开,将其转换为 8bits,然后将其保存为 png。 无论如何我不能将它保存为.jpg
img = io.imread('/content/IMG_0007_4.tif',as_gray=True)
img8 = (img/256).astype('uint8')
matplotlib.image.imsave('/content/name.png', img8)
【问题讨论】:
-
已经有一个关于使用sklearn保存jpg图片的问题了。这不是重复的,但您可以在此处找到有关如何实现结果的答案:stackoverflow.com/questions/47361966/…
-
请同时提供测试图片,以便我们看看这个特定文件是否有什么特别之处。
-
TIF 是否有图层或页面?
标签: python scikit-image