Python verification code to identify instance code, python Verification Code instance

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.