C# Class CaptchaRecogition.ImageProcess

Afficher le fichier Open project: ccccccmd/ReCapcha Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

public static Array2String ( int array, bool flag ) : string
array int
flag bool
Résultat string

Binary() public static méthode

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

CalcRate() public static méthode

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

ComputeThresholdValue() public static méthode

public static ComputeThresholdValue ( Bitmap img ) : int
img System.Drawing.Bitmap
Résultat int

ConvertImgToArrayX() public static méthode

public static ConvertImgToArrayX ( Image img ) : ].int[
img Image
Résultat ].int[

ConvertImgToArrayY() public static méthode

public static ConvertImgToArrayY ( Image img ) : ].int[
img Image
Résultat ].int[

CutImage() public static méthode

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

CutImage() public static méthode

字符数目是四个,有切割后不是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
Résultat List

GetArrayX() public static méthode

public static GetArrayX ( int input, int y ) : int[]
input int
y int
Résultat int[]

GetArrayY() public static méthode

public static GetArrayY ( int input, int x ) : int[]
input int
x int
Résultat int[]

GetBinaryCode() public static méthode

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

GetDgGrayValue() public static méthode

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

GetImgBoundaryList() public static méthode

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

GetPicValidByValue() public static méthode

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

GetPicValidByValue() public static méthode

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

GetStartBoundaryY() public static méthode

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

GetXBeyond() public static méthode

public static GetXBeyond ( int input ) : Point
input int
Résultat Point

GetYBeyond() public static méthode

public static GetYBeyond ( int input ) : Point
input int
Résultat Point

GetYZMCode() public static méthode

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

GetYZMCode() public static méthode

识别验证码(图片-->字符)
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
Résultat string

Gray() public static méthode

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

Normalized() public static méthode

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

PBinary() public static méthode

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

PreProcess() public static méthode

验证码的前期处理
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
Résultat List

RemoveBg() public static méthode

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

RemoveNoise() public static méthode

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

TrimBmp() public static méthode

public static TrimBmp ( Image img ) : Bitmap
img Image
Résultat System.Drawing.Bitmap

WriteZimo() public static méthode

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