<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>可可熊的窝 &#187; orc</title>
	<atom:link href="http://cocobear.info/blog/tag/orc/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocobear.info/blog</link>
	<description>K.I.S.S</description>
	<lastBuildDate>Sat, 10 Dec 2011 16:11:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>使用Python进行验证码识别</title>
		<link>http://cocobear.info/blog/2008/08/04/python-pic-recognize/</link>
		<comments>http://cocobear.info/blog/2008/08/04/python-pic-recognize/#comments</comments>
		<pubDate>Mon, 04 Aug 2008 08:59:16 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[编程相关]]></category>
		<category><![CDATA[orc]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/?p=298</guid>
		<description><![CDATA[以前写过一个刷校内网的人气的工具，Java的(以后再也不行Java程序了)，里面用到了验证码识别，那段代码不是我自己写的:-) 校内的验证是完全单色没有任何干挠的验证码，识别起来比较容易，不过从那段代码中可以看到基本的验证码识别方式。这几天在写一个程序的时候需要识别验证码，因为程序是Python写的自然打算用Python进行验证码的识别。 以前没用Python处理过图像，不太了解PIL(Python Image Library)的用法，这几天看了看PIL，发现它太强大了，简直和ImageMagic，PS可以相比了。(这里有PIL不错的文档) 由于上面的验证码是24位的jpeg图像，并且包含了噪点，所以我们要做的就是去噪和去色，我拿PS找了张验证码试了试，使用PS滤镜中的去噪效果还行，但是没有在PIL找到去噪的函数，后来发现中值过滤后可以去掉大部分的噪点，而且PIL里有现成的函数，接下来我试着直接把图像转换为单色，结果发现还是会有不过的噪点留了下来，因为中值过滤时把不少噪点淡化了，但转换为音色时这些噪点又被强化显示了，于是在中值过滤后对图像亮度进行加强处理，然后再转换为单色，这样验证码图片就变得比较容易识别了: 上面这些处理使用Python才几行： im = Image.open(image_name) im = im.filter(ImageFilter.MedianFilter()) enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(2) im = im.convert('1') im.show() 接下来就是提取这些数字的字模，使用shell脚本下载100幅图片，抽出三张图片获取字模： #!/usr/bin/env python #encoding=utf-8 import Image,ImageEnhance,ImageFilter import sys image_name = &#34;./images/81.jpeg&#34; im = Image.open(image_name) im = im.filter(ImageFilter.MedianFilter()) enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(2) im = im.convert('1') #im.show() #all by pixel s = [...]]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2008/08/04/python-pic-recognize/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

