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?
You can use numpy.asarray():
>>> import Image, numpy
>>> numpy.asarray(Image.open('1.jpg').convert('L'))
                        Function load will give you access to pixels like this:
b = im.load()
print b[x,y]
b[x,y] = 128    # or a tupple if you use another color mode
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With