C# Class CaptchaRecogition.ImageProcess

Mostrar archivo Open project: ccccccmd/ReCapcha Class Usage Examples

Public Methods

Method Description
Array2String ( int array, bool flag ) : string
Binary ( Bitmap img ) : Bitmap

二值化处理

CalcRate ( string t1, string t2 ) : int

计算相似度

ComputeThresholdValue ( Bitmap img ) : int
ConvertImgToArrayX ( Image img ) : ].int[
ConvertImgToArrayY ( Image img ) : ].int[
CutImage ( int RowNum, int ColNum, Bitmap bm ) : System.Drawing.Bitmap[]

图片切割

CutImage ( Image img, int ww, int hh, bool is4Chars = true, int charWidth = 10 ) : List

字符数目是四个,有切割后不是4个的话会做进一步处理

GetArrayX ( int input, int y ) : int[]
GetArrayY ( int input, int x ) : int[]
GetBinaryCode ( Bitmap img ) : string

获取图片特征码

GetDgGrayValue ( Image img ) : int

得到灰度图像前景背景的临界值 最大类间方差法

GetImgBoundaryList ( Image img, Bitmap &_bmp, bool is4Chars, int charWidth = 10 ) : List

确定是四字符会有精细处理

GetPicValidByValue ( Bitmap singlepic, int dgGrayValue ) : Bitmap

对切割后小图操作

GetPicValidByValue ( int dgGrayValue, Bitmap bm ) : Bitmap

获取有效区域

GetStartBoundaryY ( Image img, int start ) : int

Y轴开始的边界

GetXBeyond ( int input ) : Point
GetYBeyond ( int input ) : Point
GetYZMCode ( Image img, string zimoPath, int charNum ) : string

验证码识别

GetYZMCode ( Image img, string zimoPath, int maxNearPoints, int smallPicWidth, int smallPicHeight, int type = 2, bool is4Chars = true, int charWidth = 10 ) : string

识别验证码(图片-->字符)

Gray ( Bitmap img, int type = 2 ) : Image

图片灰度化处理指针法

Normalized ( Bitmap bitmap, int ww, int hh ) : Bitmap

把图片的宽高统一,归一

PBinary ( Bitmap src, int v ) : Bitmap

二值化处理

PreProcess ( Image img, int maxNearPoints, int smallPicWidth, int smallPicHeight, int type = 2, bool is4Chars = true, int charWidth = 10 ) : List

验证码的前期处理

RemoveBg ( Bitmap img, int dgGrayValue ) : Image

去除背景

RemoveNoise ( Bitmap img, int maxAroundPoints = 1 ) : Image

去除噪点

TrimBmp ( Image img ) : Bitmap
WriteZimo ( Bitmap smallPic, string zimoPath, string YZMCode ) : void

字模库维护

Private Methods

Method Description
GetEndBoundaryX ( Image img, int startX, int startY, int endY ) : int

获得X轴结束边界

GetEndBoundaryY ( Image img, int start ) : int

Y轴结束的边界

GetGrayValueByMax ( int r, int g, int b ) : int
GetGrayValueByPingjunzhi ( int r, int g, int b ) : int
GetGrayValueByQuanzhong ( int b, int g, int r ) : int
GetStartBoundaryX ( Image img, int startY, int endY ) : int

X轴开始的边界

NotFourChars ( Image img, Bitmap &_bmp, List list, int charWidth ) : List

对第一次切割后不是4张小图的做处理

Method Details

Array2String() public static method

public static Array2String ( int array, bool flag ) : string
array int
flag bool
return string

Binary() public static method

二值化处理
public static Binary ( Bitmap img ) : Bitmap
img System.Drawing.Bitmap
return System.Drawing.Bitmap

CalcRate() public static method

计算相似度
public static CalcRate ( string t1, string t2 ) : int
t1 string
t2 string
return int

ComputeThresholdValue() public static method

public static ComputeThresholdValue ( Bitmap img ) : int
img System.Drawing.Bitmap
return int

ConvertImgToArrayX() public static method

public static ConvertImgToArrayX ( Image img ) : ].int[
img Image
return ].int[

ConvertImgToArrayY() public static method

public static ConvertImgToArrayY ( Image img ) : ].int[
img Image
return ].int[

CutImage() public static method

图片切割
public static CutImage ( int RowNum, int ColNum, Bitmap bm ) : System.Drawing.Bitmap[]
RowNum int
ColNum int
bm System.Drawing.Bitmap
return System.Drawing.Bitmap[]

CutImage() public static method

字符数目是四个,有切割后不是4个的话会做进一步处理
public static CutImage ( Image img, int ww, int hh, bool is4Chars = true, int charWidth = 10 ) : List
img Image
ww int
hh int
is4Chars bool 是否是4个字
charWidth int
return List

GetArrayX() public static method

public static GetArrayX ( int input, int y ) : int[]
input int
y int
return int[]

GetArrayY() public static method

public static GetArrayY ( int input, int x ) : int[]
input int
x int
return int[]

GetBinaryCode() public static method

获取图片特征码
public static GetBinaryCode ( Bitmap img ) : string
img System.Drawing.Bitmap
return string

GetDgGrayValue() public static method

得到灰度图像前景背景的临界值 最大类间方差法
public static GetDgGrayValue ( Image img ) : int
img Image 灰度图像
return int

GetImgBoundaryList() public static method

确定是四字符会有精细处理
public static GetImgBoundaryList ( Image img, Bitmap &_bmp, bool is4Chars, int charWidth = 10 ) : List
img Image
_bmp System.Drawing.Bitmap
is4Chars bool
charWidth int
return List

GetPicValidByValue() public static method

对切割后小图操作
public static GetPicValidByValue ( Bitmap singlepic, int dgGrayValue ) : Bitmap
singlepic System.Drawing.Bitmap
dgGrayValue int
return System.Drawing.Bitmap

GetPicValidByValue() public static method

获取有效区域
public static GetPicValidByValue ( int dgGrayValue, Bitmap bm ) : Bitmap
dgGrayValue int 灰度值
bm System.Drawing.Bitmap 图片对象
return System.Drawing.Bitmap

GetStartBoundaryY() public static method

Y轴开始的边界
public static GetStartBoundaryY ( Image img, int start ) : int
img Image
start int
return int

GetXBeyond() public static method

public static GetXBeyond ( int input ) : Point
input int
return Point

GetYBeyond() public static method

public static GetYBeyond ( int input ) : Point
input int
return Point

GetYZMCode() public static method

验证码识别
public static GetYZMCode ( Image img, string zimoPath, int charNum ) : string
img Image 验证码
zimoPath string 字模位置
charNum int 验证码字符个数
return string

GetYZMCode() public static method

识别验证码(图片-->字符)
public static GetYZMCode ( Image img, string zimoPath, int maxNearPoints, int smallPicWidth, int smallPicHeight, int type = 2, bool is4Chars = true, int charWidth = 10 ) : string
img Image 验证码图片
zimoPath string 字模数据库
maxNearPoints int 噪点最大粘连数目
smallPicWidth int 切分小图宽度
smallPicHeight int 切分小图高度
type int
is4Chars bool
charWidth int
return string

Gray() public static method

图片灰度化处理指针法
public static Gray ( Bitmap img, int type = 2 ) : Image
img System.Drawing.Bitmap 待处理图片
type int 1:最大值;2:平均值;3:加权平均;默认平均值
return Image

Normalized() public static method

把图片的宽高统一,归一
public static Normalized ( Bitmap bitmap, int ww, int hh ) : Bitmap
bitmap System.Drawing.Bitmap 需要处理的图片
ww int
hh int
return System.Drawing.Bitmap

PBinary() public static method

二值化处理
public static PBinary ( Bitmap src, int v ) : Bitmap
src System.Drawing.Bitmap
v int 二值化阈值
return System.Drawing.Bitmap

PreProcess() public static method

验证码的前期处理
public static PreProcess ( Image img, int maxNearPoints, int smallPicWidth, int smallPicHeight, int type = 2, bool is4Chars = true, int charWidth = 10 ) : List
img Image 验证码图片
maxNearPoints int 噪点最大粘连数目
smallPicWidth int 切分小图宽度
smallPicHeight int 切分小图高度
type int 灰度处理方式1:最大值2:平均值3:加权平均
is4Chars bool
charWidth int
return List

RemoveBg() public static method

去除背景
public static RemoveBg ( Bitmap img, int dgGrayValue ) : Image
img System.Drawing.Bitmap 原图片
dgGrayValue int 前景背景分界灰度值
return Image

RemoveNoise() public static method

去除噪点
public static RemoveNoise ( Bitmap img, int maxAroundPoints = 1 ) : Image
img System.Drawing.Bitmap 图片
maxAroundPoints int 噪点的最大粘连数
return Image

TrimBmp() public static method

public static TrimBmp ( Image img ) : Bitmap
img Image
return System.Drawing.Bitmap

WriteZimo() public static method

字模库维护
public static WriteZimo ( Bitmap smallPic, string zimoPath, string YZMCode ) : void
smallPic System.Drawing.Bitmap 小图片
zimoPath string 字模路径
YZMCode string 验证码字符
return void