五种基于RGB色彩空间统计的皮肤检测算法

基于肤色的RGB多人脸检测 可以实现多人脸图像的检测,代码有注释,便于新手理解和学习。首先对人脸肤色的色素进行统计,如何在RGB空间下进行建立人脸肤色模型,最后使用MATLAB对其实现,准确度高,代码亲测可以实现。 立即下载

原文链接:http://blog.youkuaiyun.com/jia20003/article/details/7694408,尊重原创!

申明:文中的方法我还没有进行测试,我只是先留着以后用,我目前正在使用的人脸检测的色彩模型的效果也不错,但是在一些特殊的情况下Cover的不是很好,等有时间把这几种方法都试验一下做一个对比。

------------------------------------------------------------------------------------------------------------------------------------------------------

最近一直在研究多脸谱识别以及如何分辨多个皮肤区域是否是人脸的问题

网上找了很多资料,看了很多篇文章,将其中基于RGB色彩空间识别皮肤

的统计算法做了一下总结,统计识别方法主要是简单相比与很多其它基于

机器学习的算法,本人总结了五种RGB色彩空间的统计算法源码如下:

Skin Filter1:

[java] view plaincopy
  1. public class SkinFilter1 extends AbstractBufferedImageOp {  
  2.   
  3.     @Override  
  4.     public BufferedImage filter(BufferedImage src, BufferedImage dest) {  
  5.         int width = src.getWidth();  
  6.         int height = src.getHeight();  
  7.   
  8.         if ( dest == null )  
  9.             dest = createCompatibleDestImage( src, null );  
  10.   
  11.         int[] inPixels = new int[width*height];  
  12.         int[] outPixels = new int[width*height];  
  13.         getRGB( src, 0, 0, width, height, inPixels );  
  14.         int index = 0;  
  15.         for(int row=0; row<height; row++) {  
  16.             int ta = 0, tr = 0, tg = 0, tb = 0;  
  17.             for(int col=0; col<width; col++) {  
  18.                 index = row * width + col;  
  19.                 ta = (inPixels[index] >> 24) & 0xff;  
  20.                 tr = (inPixels[index] >> 16) & 0xff;  
  21.                 tg = (inPixels[index] >> 8) & 0xff;  
  22.                 tb = inPixels[index] & 0xff;  
  23.                   
  24.                 // detect skin method...  
  25.                 double sum = tr + tg + tb;  
  26.                 if (((double)tr/(double)tb > 1.185) &&   
  27.                     ((double)(tr*tb)/(double)(sum*sum)>0.107) &&  
  28.                     ((double)(tr*tg)/(double)(sum*sum)>0.112))  
  29.                 {  
  30.                     tr = tg = tb = 0; // black - skin detected!!  
  31.                 } else {  
  32.                     tr = tg = tb = 255; // white color means non-skin pixel  
  33.                 }  
  34.                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;  
  35.             }  
  36.         }  
  37.         setRGB( dest, 0, 0, width, height, outPixels );  
  38.         return dest;  
  39.     }  
  40. }  
Skin Filter2:

[java] view plaincopy
  1. public class SkinFilter2 extends AbstractBufferedImageOp {  
  2.   
  3.     @Override  
  4.     public BufferedImage filter(BufferedImage src, BufferedImage dest) {  
  5.         int width = src.getWidth();  
  6.         int height = src.getHeight();  
  7.   
  8.         if ( dest == null )  
  9.             dest = createCompatibleDestImage( src, null );  
  10.   
  11.         int[] inPixels = new int[width*height];  
  12.         int[] outPixels = new int[width*height];  
  13.         getRGB( src, 0, 0, width, height, inPixels );  
  14.         int index = 0;  
  15.         for(int row=0; row<height; row++) {  
  16.             int ta = 0, tr = 0, tg = 0, tb = 0;  
  17.             for(int col=0; col<width; col++) {  
  18.                 index = row * width + col;  
  19.                 ta = (inPixels[index] >> 24) & 0xff;  
  20.                 tr = (inPixels[index] >> 16) & 0xff;  
  21.                 tg = (inPixels[index] >> 8) & 0xff;  
  22.                 tb = inPixels[index] & 0xff;  
  23.                 double sum = tr + tg + tb;  
  24.                   
  25.                   
  26.                 if(((double)3*tb*tr*tr/(double)(sum*sum*sum)>0.1276)&&  
  27.                     ((double)(tr*tb+tg*tg)/(double)(tg*tb)>2.14)&&  
  28.                     ((double)(sum)/(double)(3*tr)+(double)(tr-tg)/(double)(sum)<2.7775))  
  29.                 {  
  30.                     tr = tg = tb = 0;  
  31.                 } else {  
  32.                     tr = tg = tb = 255;  
  33.                 }  
  34.                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;  
  35.             }  
  36.         }  
  37.         setRGB( dest, 0, 0, width, height, outPixels );  
  38.         return dest;  
  39.     }  
  40. }  
Skin Filter3:

[java] view plaincopy
  1. public class SkinFilter3 extends AbstractBufferedImageOp {  
  2.   
  3.     @Override  
  4.     public BufferedImage filter(BufferedImage src, BufferedImage dest) {  
  5.         int width = src.getWidth();  
  6.         int height = src.getHeight();  
  7.   
  8.         if ( dest == null )  
  9.             dest = createCompatibleDestImage( src, null );  
  10.   
  11.         int[] inPixels = new int[width*height];  
  12.         int[] outPixels = new int[width*height];  
  13.         getRGB( src, 0, 0, width, height, inPixels );  
  14.         int index = 0;  
  15.         for(int row=0; row<height; row++) {  
  16.             int ta = 0, tr = 0, tg = 0, tb = 0;  
  17.             for(int col=0; col<width; col++) {  
  18.                 index = row * width + col;  
  19.                 ta = (inPixels[index] >> 24) & 0xff;  
  20.                 tr = (inPixels[index] >> 16) & 0xff;  
  21.                 tg = (inPixels[index] >> 8) & 0xff;  
  22.                 tb = inPixels[index] & 0xff;  
  23.                   
  24.                 // detect skin method...  
  25.                 double sum = tr + tg + tb;  
  26.                 if (((double)tg / (double)tg - (double)tr / (double)tb <= -0.0905) &&  
  27.                     ((double)(sum) / (double)(3 * tr) + (double)(tr - tg) / (double)(sum) <= 0.9498))  
  28.                 {  
  29.                     tr = tg = tb = 0;  
  30.                 } else {  
  31.                     tr = tg = tb = 255;  
  32.                 }  
  33.                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;  
  34.             }  
  35.         }  
  36.         setRGB( dest, 0, 0, width, height, outPixels );  
  37.         return dest;  
  38.     }  
  39. }  
Skin Filter4:

[java] view plaincopy
  1. import java.awt.image.BufferedImage;  
  2. /** 
  3.  * this skin detection is absolutely good skin classification, 
  4.  * i love this one very much 
  5.  *  
  6.  * this one should be always primary skin detection  
  7.  * from all five filters 
  8.  *  
  9.  * @author zhigang 
  10.  * 
  11.  */  
  12. public class SkinFilter4 extends AbstractBufferedImageOp {  
  13.   
  14.     @Override  
  15.     public BufferedImage filter(BufferedImage src, BufferedImage dest) {  
  16.         int width = src.getWidth();  
  17.         int height = src.getHeight();  
  18.   
  19.         if ( dest == null )  
  20.             dest = createCompatibleDestImage( src, null );  
  21.   
  22.         int[] inPixels = new int[width*height];  
  23.         int[] outPixels = new int[width*height];  
  24.         getRGB( src, 0, 0, width, height, inPixels );  
  25.         int index = 0;  
  26.         for(int row=0; row<height; row++) {  
  27.             int ta = 0, tr = 0, tg = 0, tb = 0;  
  28.             for(int col=0; col<width; col++) {  
  29.                 index = row * width + col;  
  30.                 ta = (inPixels[index] >> 24) & 0xff;  
  31.                 tr = (inPixels[index] >> 16) & 0xff;  
  32.                 tg = (inPixels[index] >> 8) & 0xff;  
  33.                 tb = inPixels[index] & 0xff;  
  34.                   
  35.                 // detect skin method...  
  36.                 double sum = tr + tg + tb;  
  37.                 if (((double)tb/(double)tg<1.249) &&  
  38.                     ((double)sum/(double)(3*tr)>0.696) &&  
  39.                     (0.3333-(double)tb/(double)sum>0.014) &&  
  40.                     ((double)tg/(double)(3*sum)<0.108))  
  41.                 {  
  42.                     tr = tg = tb = 0;  
  43.                 } else {  
  44.                     tr = tg = tb = 255;  
  45.                 }  
  46.                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;  
  47.             }  
  48.         }  
  49.         setRGB(dest, 0, 0, width, height, outPixels);  
  50.         return dest;  
  51.     }  
  52. }  
Skin Filter5:

[java] view plaincopy
  1. import java.awt.image.BufferedImage;  
  2. /** 
  3.  * this is very good skin detection 
  4.  * get real skin segmentation correctly.... 
  5.  * ohh... cool 
  6.  *  
  7.  * @author zhigang 
  8.  * 
  9.  */  
  10. public class SkinFilter5 extends AbstractBufferedImageOp {  
  11.   
  12.     @Override  
  13.     public BufferedImage filter(BufferedImage src, BufferedImage dest) {  
  14.         int width = src.getWidth();  
  15.         int height = src.getHeight();  
  16.   
  17.         if ( dest == null )  
  18.             dest = createCompatibleDestImage( src, null );  
  19.   
  20.         int[] inPixels = new int[width*height];  
  21.         int[] outPixels = new int[width*height];  
  22.         getRGB( src, 0, 0, width, height, inPixels );  
  23.         int index = 0;  
  24.         for(int row=0; row<height; row++) {  
  25.             int ta = 0, tr = 0, tg = 0, tb = 0;  
  26.             for(int col=0; col<width; col++) {  
  27.                 index = row * width + col;  
  28.                 ta = (inPixels[index] >> 24) & 0xff;  
  29.                 tr = (inPixels[index] >> 16) & 0xff;  
  30.                 tg = (inPixels[index] >> 8) & 0xff;  
  31.                 tb = inPixels[index] & 0xff;  
  32.                   
  33.                 // detect skin method...  
  34.                 double sum = tr + tg + tb;  
  35.                 if (((double)tg/(double)tb - (double)tr/(double)tg<=-0.0905)&&  
  36.                 ((double)(tg*sum)/(double)(tb*(tr-tg))>3.4857)&&  
  37.                 ((double)(sum*sum*sum)/(double)(3*tg*tr*tr)<=7.397)&&  
  38.                 ((double)sum/(double)(9*tr)-0.333 > -0.0976))  
  39.                 {  
  40.                     tr = tg = tb = 0;  
  41.                 } else {  
  42.                     tr = tg = tb = 255;  
  43.                 }  
  44.                 outPixels[index] = (ta << 24) | (tr << 16) | (tg << 8) | tb;  
  45.             }  
  46.         }  
  47.         setRGB( dest, 0, 0, width, height, outPixels );  
  48.         return dest;  
  49.     }  

肤色检测matlab matlab肤色检测, ycbcr效果一般 立即下载

相关推荐

告别理论!手把手教你用Patran/Nastran搞定机翼颤振分析(附完整模型文件)

本文提供了一份详细的机翼颤振分析实战指南,使用Patran/Nastran软件从零开始构建完整分析模型。涵盖几何建模、网格划分、模态分析到气动弹性耦合的全流程,特别适合航空航天领域工程师学习颤振分析技术。教程包含完整模型文件和实用脚本,帮助读者快速掌握这一关键飞行器设计技能。

weixin_30879169的博客 540

目标检测中RGB和HSV颜色空间的距离度量方式

在进行彩色图像处理中,尤其是对于分割、分类和识别,都不可避免的涉及到颜色的度量。而在具体的应用中,选择哪种方式来度量颜色间的差异是一个很值得研究的问题。本文根据论文:Change Detection In Color Images的内容翻译而来,如果还要了解相关细节,请参考原文:Change Detection In Color Images。          (1)Euclidean D

Belial计算机视觉&机器视觉专栏 6852

FPGA以太网接口设计避坑指南:GMII与RGMII时序转换的三种实现方案对比

本文深入解析FPGA以太网接口设计中GMII与RGMII时序转换的三种实现方案,包括Xilinx官方IP核、手工原语逻辑和开源方案gmii_to_rgmii。通过对比分析各方案的优缺点和适用场景,为工程师提供技术选型指南,帮助避免常见设计陷阱,提升高速网络设备开发的效率和可靠性。

weixin_42570484的博客 382

RGB HSV 颜色空间 颜色距离 颜色相似度

RGB与HSV的转换 颜色相近颜色距离的概念 具体计算公式以及示例代码RGB与HSV的转换具体转换实现参考百度HSV基本概念。 各种语言的颜色API应该都提供有相关函数,直接把color转换成HSV。//android color library import android.graphics.Color;float[] tempHSV = new float[3]; Color.colorToH

咩哈哈喵喵喵 2万+

uniapp无感刷新token实现过程

可以看到已经触发了刷新token接口,并且重新请求上次失败的列表接口,无感刷新token逻辑已经正常,但为什么列表接口请求成功,还一直loading没关闭捏,就是因为后续代码未执行,await接口的返回没有成功resolve。路漫漫其修远兮,前端道路逐渐迷茫,时隔好久好久终于想起了我还有一个小博客,最近在一直在弄uniapp,属实有被恶心到,但也至少会用了,最近实现了一个比较通用的功能,就是无感刷新token,但在过程中发现一个问题就是。3、排查await的列表接口为何没有成功resolve。

weixin_40618068的博客 3594

CMake安装grpc生成gRPCTargets.cmake文件

以下是安装语句: cd grpc_folder git submodule update --init cmake .. make -j 4 sudo make install 然而编写依赖gRPC的程序,发现无法调用gRPC的CMake文件,错误提示如下所示: include could not find load file: /usr/local/lib/cmake/g...

2329

OpenCV --- 皮肤检测技术

方法一:基于RGB的皮肤检测 根据RGB颜色模型找出定义好的肤色范围内的像素点,范围外的像素点设为黑色。 查阅资料后可以知道,前人做了大量研究,肤色在RGB模型下的范围基本满足以下约束: 在均匀光照下应满足以下判别式: R>95 AND G>40 B>20 AND MAX(R,G,B)-MIN(R,G,B)>15 AND ABS(R-G)>15 AND R>G AND R>B 在侧光拍摄环境下: R>220 AND G>210 AND B&g

翻肚鱼儿的博客 1865

VPI与Matlab协同仿真:相干光通信接收端DSP算法全解析

本文详细解析了如何利用VPI与Matlab协同仿真,构建完整的相干光通信接收端DSP算法处理闭环。重点介绍了从VPI导出数据后,在Matlab中实现时钟恢复、偏振解复用和载波相位估计等核心算法的步骤与原理,并阐述了如何通过误码率计算完成仿真验证,为相干光通信系统算法研究与验证提供了高效实用的方法。

ll5678的博客 610

RGB颜色空间肤色检测

RGB颜色空间肤色检测 1.算法原理        基于RGB颜色空间的简单阈值肤色识别        在human skin color clustering for face detection一文中提出如下简单的判别算式:       R>95 And G>40 And B>20 And R>G And R>B And Max(R,G,B)-Min(R,G,B)>15 And Abs

大熊 5790

【本地部署实战】LM Studio深度使用指南:从环境搭建到模型调优

LM Studio通过极简的操作流程和强大的生态兼容性,让本地部署大模型成为可能。随着M4芯片的发布和CUDA 12.0的优化,未来本地化AI开发将迎来新的爆发点。建议开发者关注官方Discord社区(https://discord.gg/lmstudio)获取最新模型支持信息。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 8751

AttributeError: module ‘lib‘ has no attribute ‘X509_V_FLAG_CB_ISSUER_CHECK‘解决方案

本文主要介绍了AttributeError: module ‘lib’ has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK’解决方案,希望能对使用python的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 5万+

五种基于RGB色彩空间统计的皮肤检测算法 分类: 视频图像处理 ...

最近一直在研究多脸谱识别以及如何分辨多个皮肤区域是否是人脸的问题网上找了很多资料,看了很多篇文章,将其中基于RGB色彩空间识别皮肤的统计算法做了一下总结,统计识别方法主要是简单相比与很多其它基于机器学习的算法,本人总结了五种RGB色彩空间的统计算法源码如下:Skin Filter1:[java]view plaincopypublicclassSkinFilter1exten...

weixin_30666943的博客 219

Java/PHP:微信支付v3显示 “商户证书序列号有误。请使用签名私钥匹配的证书序列号。“(Spring Boot、thinkPHP微信支付失败返回错误,例如退款、企业付款到零钱等各种微信支付业务)

商户证书序列号有误。请使用签名私钥匹配的证书序列号,php,Java微信支付v3显示"商户证书序列号有误。请使用签名私钥匹配的证书序列号。"请问如何解决?httResponseBody[{"code":"SIGN_ERROR","message":"商户证书序列号有误。请使用签名私钥匹配的证书序列号"}]微信V3支付报错 平台证书及平台证书序列,vue3微信支付报错,Uniapp支付报错,微信支付签名错误解决方法,微信支付v3证书报错,微信支付平台证书过期(报错:证书序列号错误)计算签名时,商户号、商户AP

✅ 精选推荐文章 4598

图像处理之简单脸谱检测算法(Simple Face Detection Algorithm)

图像处理之简单脸谱检测算法(Simple Face Detection Algorithm) 介绍基于皮肤检测之后的,寻找最大连通区域,完成脸谱检测的算法。大致的算法步骤如下: 原图如下: 每步处理以后的效果: 程序运行,加载选择图像以后的截屏如下: ...

chuifuhuo6864的博客 179

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

6种肤色检测方法的原理及实现(opencv, C++)

6种肤色检测方法的原理及实现(opencv, C++)

Ubuntu离线安装Sogou拼音 7463

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Atitit 图像处理--图像分类 模式识别 肤色检测识别原理 与attilax的实践总结

Atitit 图像处理--图像分类 模式识别 肤色检测识别原理 与attilax的实践总结     1.1. 五中滤镜的分别效果。。1 1.2. 基于肤色的图片分类1 1.3. 性能提升2 1.4. --code2       1.1. 五中滤镜的分别效果。。   /AtiPlatf_cms/src/com/attilax/clr/skinfltAll.java

attilax的专栏 1138
上一篇: 硬盘安装Centos7可能遇到的一些问题
下一篇: 收集的一些程序员常用电子书
Virgilio
博客等级 码龄17年 33粉丝 22原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值