内容简介:这篇文章主要介绍了python验证码识别实例代码,分享了相关代码示例,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
本文研究的主要是 Python 验证码识别的相关代码,具体如下。
Talk is cheap, show you the Code!
import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans from PIL import Image #打开图像 im=np.array(Image.open('yzm.png')) #得到图像3个维度 h,w,san=im.shape X=[(h-x,y) for x in range(h) for y in range (w) if im[x][y][2]<200] #将X转换成numpy的array类型,方便后续运算操作 X=np.array(X) n_clusters=4 k_means=KMeans(init='k-means++',n_clusters=n_clusters) k_means.fit(X) k_means_labels=k_means.labels_ k_means_cluster_centers=k_means.cluster_centers_ k_means_labels_unique=np.unique(k_means_labels) colors=['#4EACC5','#FF9C34','#4E9A06','#FF3300'] plt.figure() plt.hold(True) for k,col in zip(range(n_clusters),colors): my_members=k_means_labels==k cluster_center=k_means_cluster_centers[k] plt.plot(X[my_members,1],X[my_members,0],'w',markerfacecolor=col,marker='.') plt.plot(cluster_center[1],cluster_center[0],'o',markerfacecolor=col,markeredgecolor='k',markersize=6) plt.title('KMeans') plt.grid(True) plt.show()
总结
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- C# 虹软人脸识别SDK2.0版实例
- CVPR2019| 05-17更新11篇论文及代码合集(含一篇oral,视觉跟踪/实例分割/行人重识别等)
- CVPR2019| 南开大学、Facebook等13篇CVPR论文及源码推荐(显著性检测/实例分割/人脸识别/视频动作识...
- JVM指令分析实例三(方法调用、类实例)
- 通过实例入门Golang
- Iptables详解+实例
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Where Wizards Stay Up Late
Katie Hafner / Simon & Schuster / 1998-1-21 / USD 16.00
Twenty five years ago, it didn't exist. Today, twenty million people worldwide are surfing the Net. "Where Wizards Stay Up Late" is the exciting story of the pioneers responsible for creating the most......一起来看看 《Where Wizards Stay Up Late》 这本书的介绍吧!