Python verification code to identify instance code, python Verification Code instance
This article focuses on the Python verification code identification, as detailed below.
Talk is cheap, show you the Code!
Import numpy as npimport matplotlib. pyplot as pltfrom sklearn. cluster import KMeansfrom PIL import imageloud to open the image like immo-np.array(image.open('yzm.png ') # obtain the image in three dimensions: h, w, san = im. shapeX = [(h-x, y) for x in range (h) for y in range (w) if im [x] [y] [2] <200] # converts X to the array type of numpy for subsequent computation 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 = 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 ()
Summary
The above is all the content about the python verification code recognition instance code in this article. I hope it will help you. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!