Save 32-bit floating point TIFF image

最后都变了- 提交于 2021-01-27 14:38:52

问题


I'm trying to save a 32-bit floating point image (stored as a Numpy array) as a TIFF file using tifffile.py.

import numpy as np
import tifffile

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

However, when viewing the output of the above code in Eye of Gnome, the image is entirely blank.


回答1:


I think the problem is that not all tools support multi-channel TIFFs with 32-bits per channel. For example, as far as I can tell Python's PIL library does not. But I think tifffile.py does, because if I use your code I get a TIFF that opens, and looks reasonable, in GIMP:

From what I read, Photoshop can read 32-bit TIFFs too. So I think the TIFF file contains your image, but whether it works for you or not depends on what you want to do with it next.

This question might be relevant too, although it's about using 16-bit integers not floats: Python: Read and write TIFF 16 bit , three channel , colour images



来源:https://stackoverflow.com/questions/57932630/save-32-bit-floating-point-tiff-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!