Linked Questions

Popular Questions

PIL image to array (numpy array to array) - Python

Asked by At

I have a .jpg image that I would like to convert to Python array, because I implemented treatment routines handling plain Python arrays.

It seems that PIL images support conversion to numpy array, and according to the documentation I have written this:

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

print(list(np.asarray(im)))

This is returning a list of numpy arrays. Also, I tried with

list([list(x) for x in np.asarray(im)])

which is returning nothing at all since it is failing.

How can I convert from PIL to array, or simply from numpy array to Python array?

Related Questions