Python get image matrix PIL

numpypythonpython-imaging-library

i am trying to get to load an image, convert it and print the matrix. I have the following code ;

im = Image.open("1.jpg")
im = im.convert("L")
print im

when i print 'im' i get this <PIL.Image.Image image mode=L size=92x112 at 0x2F905F8> . How can i get to see the image matrix?

Best Answer

You can use numpy.asarray():

>>> import Image, numpy
>>> numpy.asarray(Image.open('1.jpg').convert('L'))