Verification code recognition-verification code signature

Source: Internet
Author: User
1. Download remote Images
2. grayscale conversion
3. image splitting
4. Obtain the image segmentation pattern by grayscale

(The verification code signature for the image change is not very accurate)
The color is the image obtained from the original website.
Gray is the converted grayscale image.
The following is the split image.
The following list shows the signature.
Grayscale conversion is the code 1/** // <summary>
2 // grayscale conversion, point-by-point
3 /// </summary>
4 public void GrayByPixels ()
5 {
6 for (int I = 0; I <bmpobj. Height; I ++)
7 {
8 for (int j = 0; j <bmpobj. Width; j ++)
9 {
10 int tmpValue = GetGrayNumColor (bmpobj. GetPixel (j, I ));
11 bmpobj. SetPixel (j, I, Color. FromArgb (tmpValue, tmpValue, tmpValue ));
12}
13}
14}

Image segmentation public Bitmap [] getsplitpicsbyblkcol (int RowNum, int dgGrayValue)
{
If (RowNum = 0)
Return null;
Int singW = bmpobj. Width/RowNum;
Bitmap [] PicArray = new Bitmap [RowNum];

Rectangle cloneRect;
Int MinCol = 0, OldCol = 0;
Int Points, MinPoints;
For (int j = 0; j <RowNum-1; j ++)
{
MinPoints = bmpobj. Height;
For (int k = j * singW; k <(j + 1) * singW + singW/2; k ++) // find the smallest vertex Sequence
{
Points = 0;
For (int I = 0; I <bmpobj. Height; I ++)
{
If (bmpobj. GetPixel (k, I). R <dgGrayValue) // count
Points ++;
}
If (Points <MinPoints)
{
If (k-j * singW> singW/2) // the second half of the character
{
MinPoints = Points;
MinCol = k;
}
}
}
If (MinCol-OldCol + 1 <= singW/2) // less than half of the width
MinCol = (j + 1) * singW;
// Extract small plot
If (MinPoints> 0) // There is an intersection
CloneRect = new Rectangle (OldCol, 0, MinCol-OldCol + 1, bmpobj. Height );
Else
CloneRect = new Rectangle (OldCol, 0, MinCol-OldCol, bmpobj. Height );

OldCol = MinCol;
PicArray [j] = bmpobj. Clone (cloneRect, bmpobj. PixelFormat); // copy a small image
}
CloneRect = new Rectangle (OldCol, 0, bmpobj. Width-OldCol, bmpobj. Height );
PicArray [RowNum-1] = bmpobj. Clone (cloneRect, bmpobj. PixelFormat); // The Last
Return PicArray;
}

Whether the verification code can be obtained accurately or when the grayscale conversion is required, the grayscale value is obtained moderately, and the correct signature can be obtained through accurate segmentation. It is very easy to recognize common image verification codes.

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.