Python verification code recognition-Pre-processing

Source: Internet
Author: User

At present, the verification codes of many systems are becoming more and more complex and difficult to recognize by human eyes, especially for verification codes such as QQ. It is too difficult to identify them.

There is a verification code:

Generally, the verification codes are pre-processed, split, and identified. This verification code has no other noise, but there is a cross curve interference, and the font in the verification code is stuck together.

If the interference curve is not removed, the whole recognition will be affected. To solve this problem, first remove this curve. The first method is to obtain the first position of the curve (X, y), this part is very simple,CodeAs follows:

 1   Def  Get_left_start_point (IM ):
2 Start_point = (0, 0)
3 Found = False
4 W, h = Im. Size
5 Data = List (IM. getdata ())
6 For X In Xrange (W ):
7 For Y In Xrange (h ):
8 If Data [y * W + X] ! = White :
9 Found = True
10 Start_point = (X, y)
11 Break
12
13 If Found:
14 Break
15 Return Start_point

After obtaining the header node, traverse it from left to right in sequence to determine whether it is a black spot, save the Coordinate Position of the line, and then remove the line position (thanks to Sun zhihai's friend) (CODE)

 

So we can get the image after removing the black line:

Except for several isolated points, the black lines in the image are basically removed. Below are some of the items that are better processed:

The following process is poor:

In view of the fact that the previous Blog content has been reposted on the Internet and does not indicate the source, add the following content:

Author: External oon

Homepage: http://qtrstudio.com

Blog: http://www.cnblogs.com/ubunoon; http://qtrstudio.com/blog

Email: netubu # gmail.com

Copyright: Copyright 2011. All rights reserved.

Related Article

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.