for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
p[0] = p[1] = p[2] = (int)vSource[x, y] > 161 ? (byte)255 : (byte)0;
//p[0] = p[1] = p[2] = (int)GetAverageColor(vSource, x, y, w, h) > 50 ? (byte)255 : (byte)0;
p += nn;
}
p += offset;
}
bmpDest.UnlockBits(dataDest);
orcbmp = bmpDest;
orcbmp.Save("d:二值化.png");
pictureBox29.Image = Image.FromFile("d:二值化.png");
}
//OCR的值
if (orcbmp != null)
{
string result = Ocr(orcbmp);
label32.Text = result.Replace("n", "rn").Replace(" ", "");
}
}
C#识别验证码图片通用类
-
using System;
using System.Collections.Generic;
-
using System.Text;
using System.Collections;
-
using System.Drawing;
using System.Drawing.Imaging;
-
using System.Runtime.InteropServices;
-
namespace BallotAiying2
{
-
class UnCodebase
{
-
public Bitmap bmpobj;
public UnCodebase(Bitmap pic)