Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 626 Bytes

README.md

File metadata and controls

33 lines (22 loc) · 626 Bytes

Sipo3

关于最最简单的计算题验证码,还是接着之前的思路。灰度图-> 二值化 -> 切割 -> knn

环境依赖

numpy, pillow, sklearn

灰度图、二值化

image = np.asarray(Image.open(os.path.join('label', file)).convert('L'))
image = (image > 135) * 255

切割

letters = [image[:, 6:18].reshape(20*12), image[:, 19:31].reshape(20*12), image[:, 33:45].reshape(20*12), image[:, 45:57].reshape(20*12)]

训练

knn = KNeighborsClassifier()
knn.fit(np.asarray(train_x), np.asarray(train_y))

总结

太过简单,不在赘述