国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python驗證碼識別實例代碼

2020-02-22 23:06:33
字體:
來源:轉載
供稿:網友

本文研究的主要是Python驗證碼識別的相關代碼,具體如下。

Talk is cheap, show you the Code!

import numpy as npimport matplotlib.pyplot as pltfrom sklearn.cluster import KMeansfrom PIL import Image#打開圖像im=np.array(Image.open('yzm.png'))#得到圖像3個維度h,w,san=im.shapeX=[(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=4k_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()

總結

以上就是本文關于python驗證碼識別實例代碼的全部內容,希望對大家有所幫助。感興趣的朋友可以繼續參閱本站其他相關專題,如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平度市| 崇左市| 景东| 武穴市| 平遥县| 探索| 太原市| 镇平县| 韩城市| 临武县| 东乌珠穆沁旗| 东平县| 永新县| 泗洪县| 灵宝市| 徐水县| 获嘉县| 合作市| 扶绥县| 西藏| 荆州市| 嘉峪关市| 鄂伦春自治旗| 若尔盖县| 图木舒克市| 鱼台县| 姚安县| 彭阳县| 广元市| 武夷山市| 景德镇市| 龙游县| 山丹县| 漳平市| 乐亭县| 巴青县| 镇安县| 清水县| 西林县| 昌宁县| 泾阳县|