第一節 讀取圖片
1.安裝PIL,numpy
2.使用open函數讀取圖片
3.使用numpy的array使得圖像變成矩陣,有利於後續處理
代碼如下:
from PIL import Image
from numpy import array
im=Image.open('2.jpg')
# print im.shape
im1=im.convert('L')
im1=array(im1)
print im1
print im1.shape
結果:
[[149 149 149 ..., 149 149 149]
[149 149 149 ..., 149 149 149]
[149 149 149 ..., 149 149 149]
...,
[151 151 151 ..., 149 148 149]
[151 151 151 ..., 149 148 149]
[151 151 151 ..., 149 148 149]]
(476L, 440L)
未完待續。。。。。。。。。。。