相关疑难解决方法(0)

PIL图像到数组(numpy数组到数组) - Python

我有一个.jpg图像,我想转换为Python数组,因为我实现了处理普通Python数组的处理例程.

似乎PIL图像支持转换为numpy数组,并且根据我写的文档:

from PIL import Image
im = Image.open("D:\Prototype\Bikesgray.jpg")
im.show()

print(list(np.asarray(im)))
Run Code Online (Sandbox Code Playgroud)

这将返回一个numpy数组列表.另外,我试过了

list([list(x) for x in np.asarray(im)])
Run Code Online (Sandbox Code Playgroud)

由于它失败了,它什么都没有返回.

如何从PIL转换为数组,或者简单地从numpy数组转换为Python数组?

python arrays numpy image python-imaging-library

21
推荐指数
3
解决办法
9万
查看次数

标签 统计

arrays ×1

image ×1

numpy ×1

python ×1

python-imaging-library ×1