Ror*_*ter 7 python numpy python-imaging-library
我试图加载图像,转换它并打印矩阵.我有以下代码;
im = Image.open("1.jpg")
im = im.convert("L")
print im
Run Code Online (Sandbox Code Playgroud)
当我打印'即时'我得到这个<PIL.Image.Image image mode=L size=92x112 at 0x2F905F8>.我怎样才能看到图像矩阵?
Ble*_*der 12
你可以使用numpy.asarray():
>>> import Image, numpy
>>> numpy.asarray(Image.open('1.jpg').convert('L'))
Run Code Online (Sandbox Code Playgroud)
函数加载将允许您访问像这样的像素:
b = im.load()
print b[x,y]
b[x,y] = 128 # or a tupple if you use another color mode
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19054 次 |
| 最近记录: |