简体   繁体   English

matplotlib.image.imsave TypeError:无法将图像数据转换为float

[英]matplotlib.image.imsave TypeError: Image data cannot be converted to float

Simplest fail case: 最简单的失败案例:

import matplotlib.image as mpimg
path = 'test_images/input.jpg'
temp = mpimg.imread(path)
mpimg.imsave(temp, 'output.jpg')

I get: 我得到:

line 1347, in imsave
image.set_data(arr)
File "/Users/chris/anaconda3/lib/python3.5/site-packages/matplotlib/image.py", 
line 600, in set_data
raise TypeError("Image data cannot be converted to float")

I have tested that the file exists (putting the above code in a if os.path.isfile(path): test) and printed the temp.shape which gives me the expected results. 我已经测试了文件是否存在(将上面的代码放入if os.path.isfile(path):test中),并打印了temp.shape,它给了我预期的结果。 Be grateful for any assistance. 感谢您的协助。

I believe there is a mismatch in arguments. 我认为论点不符。

mpimg.imsave(temp, 'output.jpg') instead try, mpimg.imsave(temp, 'output.jpg')代替,

mpimg.imsave('output.jpg', temp)

Documentation here. 这里的文档。 imsave imsave

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python:如何使用 matplotlib.image.imsave() 将 EXACT numpy 数组数据保存到图像 - Python: How to save EXACT numpy array data to image using matplotlib.image.imsave() 类型错误:图像数据无法转换为浮点数 - TypeError: Image data cannot be converted to float 类型错误:无法将图像数据转换为浮点数 无法将图像数据转换为浮点数 - TypeError: Image data cannot be converted to float Image data cannot be converted to float TypeError:图像数据无法转换为少量图像浮动 - TypeError: Image data cannot be converted to float for few images 类型错误:dtype 对象的图像数据无法转换为浮点数 - TypeError: Image data of dtype object cannot be converted to float TypeError:图像数据无法在 wordcloud 项目上转换为浮点数 - TypeError: Image data cannot be converted to float on wordcloud project Python OpenCV 错误:“类型错误:图像数据无法转换为浮点数” - Python OpenCV Error: “TypeError: Image data cannot be converted to float” plt.imshow()给出TypeError(“图像数据无法转换为浮点数”) - plt.imshow() giving TypeError(“Image data cannot be converted to float”) TypeError:加载.npy文件时,图像数据无法转换为float - TypeError: Image data cannot be converted to float while loading .npy file TypeError: 图片数据不能转换为float // 导入.png图片时 - TypeError: Image data cannot be converted to float // When importing .png images
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM