Python:如何保存rgb浮点图像?
我尝试将RGB浮点图像保存到tiff文件,但找不到方法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
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
: