转换图片格式的时候,出现错误:TypeError: Cannot handle this data type: (1, 1), <i8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Traceback (most recent call last): File "/Users/mcj/opt/anaconda3/envs/py3/lib/python3.6/site-packages/PIL/Image.py", line 2714, in fromarray mode, rawmode = _fromarray_typemap[typekey] KeyError: ((1, 1), '<i8') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/mcj/.nutstore/.nutstore/荔枝面条/07 学习资料/07 代码/PycharmProject/算法集合/将图片转为矩阵/imgtomatrix.py", line 27, in <module> loadImage() File "/Users/mcj/.nutstore/.nutstore/荔枝面条/07 学习资料/07 代码/PycharmProject/算法集合/将图片转为矩阵/imgtomatrix.py", line 22, in loadImage new_im = Image.fromarray(data) File "/Users/mcj/opt/anaconda3/envs/py3/lib/python3.6/site-packages/PIL/Image.py", line 2716, in fromarray raise TypeError("Cannot handle this data type: %s, %s" % typekey) TypeError: Cannot handle this data type: (1, 1), <i8 进程已结束,退出代码 1 |
解决如下:
将:new_im = Image.fromarray(data)
改为:new_im = Image.fromarray(np.uint8(data))
看看
有一事请教,我是业余玩家。 sudo vi /etc/sudoers这个命令须在root用户下执行,弹出页面为只读。 所以我执行的是sudo nano /etc/sudoers,弹出的页面就能修改
感谢分享,这个网站真不赖
看看好不好用
这篇文章实在是太赞了,做学术的那种恪尽职守和严肃认真,全篇简明扼要没有一句废话。我引用的博主的链接。 https://www.right.com.cn/forum/forum.php?mod=r
cccc学习学习下
答案
我想卡