读书人

paip.验证码判别---判断图片是否是

发布时间: 2013-03-01 18:33:02 作者: rapoo

paip.验证码识别---判断图片是否是彩色图片
paip.验证码识别---判断图片是否是彩色图片






----作者Attilax , 1466519819@qq.com---




RGB颜色,就是用红、绿、蓝三个分量组成的颜色,.NET中用Color类来表示,HSL颜色,就是用色调(Hue)、饱和度(Saturation)、


亮度(Lightness)来描绘一个颜色,


判断验证码图片不能直接用普通色彩判断的方法,因为它可能只是有彩色小噪点,但总体上仍然是黑白的……




经过我的总结:要点如下。


判断彩色点;我在画图程序中,看到一个彩色点的S阀值是30左右。也就是说超过30就算是彩色点了。但在我上网搜集的RGB转HSL代


码中,S值 MS比画图程序的大10左右……


判断彩色图片:分别记录黑白点和菜色点。如果比率大于10%,一般可认为是彩色图片了……当然视不同网站的验证码而定……








namespace MOLE.yejenma
{
public class urlorRRV3 : Iurlor








private bool iscolorImage(Image img)
{ //public static void colorFejweC29(Bitmap bmp)
{
int hbye=0;
int kala=0;
Bitmap bmp=(Bitmap)img;
int N = bmp.Width; //image's width
int M = bmp.Height;//image's height
Color t, m;
int i, j, red, green, blue;
for (i = 0; i < N; i++)
for (j = 0; j < M; j++)
{


t = bmp.GetPixel(i, j);
HSLColor hslc = new HSLColor(t);
if (hslc.Saturation*255 < 40)
hbye++;
else
kala++;







}


///end for
float flt=(kala/hbye);
if (flt > 0.1)
return true;
else
return false;
// this.Invalidate();
}

}












参考:
C# RGB颜色与HSL颜色的转换与HSL颜色的应用

读书人网 >网络基础

热点推荐