验证码识别技术(二)去除图片背景
2015-08-14 16:28
295 查看
去除图片的背景,这里有一个基本的分析方法,可以下载下来几个验证码,然后,把像点读出,导入到EXCEL文件中,自动生成散点图,通过散点图,能很快的分析出背景的值是多少,根据这个值,去处理背景很方便。
例如:
原始的验证码为
通过程序分析
比如评出的值为500左右。
去除背景的图片为:
相关的代码如下所示。
例如:
原始的验证码为
通过程序分析
比如评出的值为500左右。
去除背景的图片为:
相关的代码如下所示。
/** * 去除图片的背景(二值化) * * @param picFile 图片的文件全名 * @return 图片结构 * @throws Exception */ public static BufferedImage StartRemove(String picFile) throws Exception { BufferedImage img = ImageIO.read(new File(picFile)); int width = img.getWidth(); int height = img.getHeight(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (isWhite(img.getRGB(x, y)) == 1) { img.setRGB(x, y, Color.WHITE.getRGB()); } else { img.setRGB(x, y, Color.BLACK.getRGB()); } } } return img; } // 其中一个像素点是否有效 private static int isWhite(int colorInt) { Color color = new Color(colorInt); int sumPix = color.getRed() + color.getGreen() + color.getBlue(); //// 测试 //System.out.println(sumPix); if (sumPix > 500) { return 1; } else { return 0; } }
相关文章推荐
- gradle
- JS中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
- AOE网上的关键路径
- C# 语言和 .NET Framework 介绍
- 0000002_java学习之路_验证码的使用
- Android framework系统默认设置修改
- ACdream1077 LCM Challenge 数学题
- oracle 分组后,求和
- POJ 3274 Gold Balanced Lineup
- python 之 解决中文字符异常
- asp.net 批量下载实现(打包压缩下载)
- 微信公众平台开发(76) 获取用户基本信息
- C#关于log4net(Log For Net)
- Android基于mAppWidget实现手绘地图(十五)–如何控制放大缩小
- 重装Oracle 10g RAC如何干净的清理系统
- HDU 2029
- 比较优秀的软件记录
- zip, tar, tar.gz, tar.bz2, jar,7z等格式文件的压缩和解压方法
- 线程同步的五种方法
- HDU 3469 Catching the Thief (博弈 + DP递推)