python - 保存 32 位浮点 TIFF 图像

标签 python image numpy tiff

我正在尝试使用 tifffile.py 将 32 位浮点图像(存储为 Numpy 数组)保存为 TIFF 文件.

import numpy as np
import tifffile

image = np.random.rand(500, 500, 3).astype(np.float32)
tifffile.imsave('image.tiff', image)

但是,当在 Eye of Gnome 中查看上述代码的输出时,图像完全是空白的。

Screenshot

最佳答案

我认为问题在于并非所有工具都支持每 channel 32 位的多 channel TIFF。例如,据我所知,Python 的 PILdoes not 。但我认为tifffile.py确实如此,因为如果我使用你的代码,我会得到一个在 GIMP 中打开且看起来合理的 TIFF:

GIMP with the image

据我所知,Photoshop 也可以读取 32 位 TIFF。所以我认为 TIFF 文件包含您的图像,但它是否适合您取决于您​​接下来想要用它做什么。

这个问题可能也相关,尽管它是关于使用 16 位整数而不是 float :Python: Read and write TIFF 16 bit , three channel , colour images

关于python - 保存 32 位浮点 TIFF 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57932630/

相关文章:

python - 拆分字符串时正则表达式模式中的括号

python - 单行for循环构建字典?

c++ - 有哪些代码生成技术?

html - 如何在 CSS 中将跨度文本居中放置在图像旁边

php - 创建在线相册的首选方法是什么?

javascript - 如果单击 Canvas 中的图像,则会发出警报

python - 在 numpy 数组中切片和在 Python 中切片有什么区别?

python - 在 Azure Web 角色上安装 Numpy 时出现 "No space left on device"

python - cURL 发送 JSON 和 PDF 文件

python - numpy 将切片 append 到二维数组以使其成为三维数组