怎样去除验证码中的细线

gxh973121 2007-07-24 05:03:38
中值滤波可以,但会使原图形失真,有没有其他不使原图失真的方法呢,最好有代码
图片可见(http://s2.warlord.cn/validateImg.jsp)
...全文
763 32 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
32 条回复
切换为时间正序
请发表友善的回复…
发表回复
panzi667 2007-09-18
  • 打赏
  • 举报
回复
学习中~~~
jess_lv 2007-09-18
  • 打赏
  • 举报
回复
记得多给点分就是了,!
jess_lv 2007-09-18
  • 打赏
  • 举报
回复
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.ComponentModel;
using System.Web.SessionState;
using System.Drawing;
using System.Web.UI.HtmlControls;



public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
CreateCheckCodeImage(GenerCheckCode());
}
private string GenerCheckCode()
{
int numbeer;
char code;
string checkcode=string.Empty;
System.Random random=new Random();
for(int i=0;i<4;i++)
{
numbeer=random.Next();
code=(char)('0'+(char)(numbeer%10));
checkcode +=code.ToString();
}
Session["CheckCode"]=checkcode;
return checkcode;
}
private void CreateCheckCodeImage(string chcekcode)
{
if (chcekcode == null || chcekcode.Trim() == string.Empty) return;
System.Drawing.Bitmap image=new System.Drawing.Bitmap((int)Math.Ceiling((chcekcode.Length*12.5)),22);
Graphics g=Graphics.FromImage(image);
try{
Random random=new Random();
g.Clear(Color.White);
//背景己线形式出现
//for(int i=0;i<25;i++)
//{
// int x1=random.Next(image.Width);
// int x2=random.Next(image.Width);
// int y1=random.Next(image.Height);
// int y2=random.Next(image.Height);
// g.DrawLine(new Pen(Color.Silver),x1,y1 ,x2,y2);
//}
//背景己点形式出现
for (int i = 0; i < 100; i++)
{
int x1 = random.Next(image.Width);
int y1 = random.Next(image.Height);
image.SetPixel(x1, y1, Color.FromArgb(random.Next()));
// image.SetPixel(x1, y1, Color.Yellow);



}
Font font=new System.Drawing.Font("Arial",13,(System.Drawing.FontStyle.Bold));
System.Drawing.Drawing2D.LinearGradientBrush brush=new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0,0,image.Width,image.Height),Color.Blue,Color.DarkRed,1.2f,true);
g.DrawString(chcekcode,font,brush,4,2);
g.DrawRectangle(new Pen(Color.Silver),0,0,image.Width-1,image.Height-1);
System.IO.MemoryStream ms=new System.IO.MemoryStream();
image.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType="image/Gif";
Response.BinaryWrite(ms.ToArray());
}finally{
g.Dispose();
image.Dispose();
}
}
}
ysgan 2007-09-18
  • 打赏
  • 举报
回复
关注中
liuyun1987 2007-09-18
  • 打赏
  • 举报
回复
不晓滴。
友情帮顶。
只看过加细线的代码。。
mrshelly 2007-09-18
  • 打赏
  • 举报
回复
楼主提供的这个破解应该太容易....

1 颜色阀值(文字颜色与干扰纹颜色 相差太大)

2 字体规则

3 字符单体颜色统一

单这三条. 破解难度已经降到很氏了....
mrshelly 2007-09-18
  • 打赏
  • 举报
回复
颜色阐值.... 忽略非文字颜色的点
panzi667 2007-09-18
  • 打赏
  • 举报
回复
忽略细线
yygyogfny 2007-07-30
  • 打赏
  • 举报
回复
不会啊,,学习~
huiaccp 2007-07-30
  • 打赏
  • 举报
回复
頂一下
wwqna 2007-07-30
  • 打赏
  • 举报
回复
不知道你所谓不失真是什么意思

源代就没有了,我试了一下,方法大致如

直接二值化->四临域像素值 + 自身像素值- 255 就是转变之后自身相素值

这时图像上会有几个孤点,你自己再去滤一下吧
gxh973121 2007-07-30
  • 打赏
  • 举报
回复
这里不能贴图,要不我可以贴出来别人处理后的图片,真的是把细线去掉了,大家继续讨论呀
DotGod 2007-07-26
  • 打赏
  • 举报
回复
jf
Jinglecat 2007-07-26
  • 打赏
  • 举报
回复
up
bb1210 2007-07-26
  • 打赏
  • 举报
回复
学习
mountainking1986 2007-07-26
  • 打赏
  • 举报
回复
源代码!!!
kingonehappy 2007-07-26
  • 打赏
  • 举报
回复
图像处理 学习
zhuawang 2007-07-25
  • 打赏
  • 举报
回复
up
gxh973121 2007-07-25
  • 打赏
  • 举报
回复
ding
zpingy 2007-07-25
  • 打赏
  • 举报
回复
怎么产生的?没看明白
不过为什么非要做这么难看的呢?验证的级别有那么高?防止别人仿造?
加载更多回复(12)

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧