Python基于YCbCr 肤色模型的情色图片检测的简单实现
2015-01-27 13:03
871 查看
<span style="color: rgb(54, 46, 43); font-family: Arial; font-size: 14px; line-height: 26px;"><strong>Python基于YCbCr 肤色模型的情色图片检测的简单实现</strong></span>
#Detection of Pornographic Digital Images #YCbCr Model #author:Robin chen #input:the dir of an image ''' ref: 1.http://www.naun.org/multimedia/NAUN/computers/20-462.pdf 2.http://blog.csdn.net/gzlaiyonghao/article/details/3166735 ''' from PIL import Image import sys def image_ifo(image): try: img = Image.open(image) except Exception,e: print "Can not open the image!" print 'Image Mode:%s,Image Size:%s,Image Format:%s' % (img.mode,img.size,img.format) return img def preprocessed_image(image): img = image_ifo(image) if not img.mode == 'YCbCr': img = img.convert('YCbCr') return img def detector(image): img = preprocessed_image(image) ycbcr_data = img.getdata() W,H = img.size THRESHOLD = 0.3 count = 0 for i,ycbcr in enumerate(ycbcr_data): y,cb,cr = ycbcr #if 80 <= cb <= 120 and 133 <= cr <= 173: if 86 <= cb <= 127 and 130 <= cr < 168: count += 1 if count > THRESHOLD*W*H: print 'The image is pornographic!' else: print 'The image is not pornographic!' if __name__ == '__main__': image = sys.argv[-1] print 'Detector is working on it,please wait a second...' detector(image) print 'Detecting is done!'
相关文章推荐
- 基于YCbCr的肤色检测OpenCV实现
- 基于jquery的lazy loader插件实现图片的延迟加载[简单使用]
- 基于肤色和眼睛定位的人脸检测算法——MATLAB实现【转】
- 基于jquery单击图片弹出显示的简单实现
- Python基于twisted实现简单的web服务器
- python基于mysql实现的简单队列以及跨进程锁实例详解
- 一个简单的 python 实现 图片同步脚本 ,对于有图片群集的项目有参考价值
- 肤色检测算法 - 基于不同颜色空间简单区域划分的皮肤检测算法
- python基于mysql实现的简单队列以及跨进程锁
- 肤色检测算法 - 基于不同颜色空间简单区域划分的皮肤检测算法
- Python基于twisted实现简单的web服务器
- 简单的基于YCrCb颜色空间的人脸检测(肤色)
- 一个简单基于LRU连接检测实现
- 肤色检测算法 - 基于二次多项式混合模型的肤色检测。
- 基于肤色和眼睛定位的人脸检测算法——MATLAB实现
- Android实现基于肤色的皮肤检测
- 肤色检测算法 - 基于不同颜色空间简单区域划分的皮肤检测算法
- python用10行代码实现黄色图片检测
- python 简单实现 图片百叶窗效果
- python基于mysql实现的简单队列以及跨进程锁实例详解