Python获取图像矩阵PIL [英] Python get image matrix PIL

查看:69
本文介绍了Python获取图像矩阵PIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试加载图像,将其转换并打印矩阵.我有以下代码;

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

当我打印'im'时,我得到这个<PIL.Image.Image image mode=L size=92x112 at 0x2F905F8>.我怎样才能看到图像矩阵?

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?

推荐答案

您可以使用numpy.asarray():

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

这篇关于Python获取图像矩阵PIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆