In [1]:
from PIL import Image
from numpy import array

In [2]:
#把彩色图像转化为灰度图像。RBG转化到HSI彩色空间,采用I分量:
img = Image.open("a57w.png")
img = img.convert("L")
img


Out[2]:

In [3]:
def initTable(threshold=135):
 table = []
 for i in range(256):
     if i < threshold:
         table.append(0)
     else:
         table.append(1)

 return table

In [4]:
b_img = img.point(initTable(), '1')
b_img


Out[4]:

In [12]:
b_img.crop((20, 0, 55, 100))


Out[12]:

In [6]:
b_img.crop((55, 0, 90, 100))


Out[6]:

In [7]:
b_img.crop((90, 0, 125, 100))


Out[7]:

In [8]:
b_img.crop((125, 0, 170, 100))


Out[8]:

In [13]:
from sklearn import svm

In [ ]:
sv