Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:如何保存rgb浮点图像?_Python_Image_Python 2.7_Python Imaging Library - Fatal编程技术网

Python:如何保存rgb浮点图像?

Python:如何保存rgb浮点图像?,python,image,python-2.7,python-imaging-library,Python,Image,Python 2.7,Python Imaging Library,我尝试将RGB浮点图像保存到tiff文件,但找不到方法 from PIL import Image imgf = np.ones((5,5,3),dtype = np.float32) img_to_save = Image.fromarray(imgf) #fails.. img_to_save.save('img.tiff') 或者,matplotlib.pyplot imsave将我的浮点值更改为整数 我该怎么做?有多种LIB可供选择。例如libtiff或者如果我还正确地记得PIL(Py

我尝试将RGB浮点图像保存到tiff文件,但找不到方法

from PIL import Image
imgf = np.ones((5,5,3),dtype = np.float32)
img_to_save = Image.fromarray(imgf) #fails..
img_to_save.save('img.tiff')
或者,matplotlib.pyplot imsave将我的浮点值更改为整数


我该怎么做?

有多种LIB可供选择。例如libtiff或者如果我还正确地记得PIL(Python图像库),假设
plt
matplotlib.pyplot
,那么
plt.imsave
的参数是反向的。它应该是
plt.imsave(测试文件名,imgf)
。如果这对您有效,您不需要创建
图像
imsave
可以从numpy数组创建文件。@Warren Weckesser plt.imsave将浮动更改为intsLooks,如Pillow不支持浮点RGB:您可以尝试
tiffile