原文:Win8 Metro(C#)数字图像处理--2.47人脸红眼去除算法



[函数名称]

  红眼去除     RedeyeRemoveProcess(WriteableBitmap src)

        /// <summary>
/// Redeye remove Process.
/// </summary>
/// <param name="src">The source image.</param>
/// <returns></returns>
public static WriteableBitmap RedeyeRemoveProcess(WriteableBitmap src)////红眼去除
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap srcImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
byte[] tempMask = (byte[])temp.Clone();
int r, g, b;
int Rc, Gc, Bc;
for (int i = 0; i < temp.Length; i += 4)
{
b = tempMask[i];
g = tempMask[i + 1];
r = tempMask[i + 2];
if (r > (int)(g + b))//这里 只是简单的判断一下红眼像素只为说明红眼去除算法,实际上要使用一定的红眼判断算法决策
{
Rc = (int)((g + b) / 2);
Gc = (int)((g + Rc) / 2);
Bc = (int)((b + Rc) / 2);
temp[i] = (byte)Bc;
temp[i + 1] = (byte)Gc;
temp[i + 2] = (byte)Rc;
}
}
Stream sTemp = srcImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return srcImage;
}
else
{
return null;
}
}

[图像效果]

最新文章

  1. ecshop 多表删除
  2. some code of c
  3. Zepto 使用过程中遇到的问题总结
  4. Ghost博客安装
  5. Android应用反破解的思路
  6. BigDecimal类的加减乘除
  7. 浅谈压缩感知(三十):压缩感知重构算法之L1最小二乘
  8. ARCGIS10.1 GeoDatabase深入理解:客户端连接与退出地理数据库时系统表的初始化
  9. c# 并行运算
  10. ios-XML文档解析之SAX解析
  11. LoadRunner 录制cas 登陆脚本
  12. 摸索出来的chrom调试前后台数据(Java&amp;&amp;Ajax)交互的方法分享一下咯!!!
  13. js的内置对象
  14. python函数调用之自我调用与C++比较
  15. 深度召回模型在QQ看点推荐中的应用实践
  16. jdbc.properties+web.xml
  17. ABAP接口之Http发送json报文
  18. Confluence 6 在初始化配置时候的问题
  19. Cocos Creator两个类相互引用(调用)
  20. Ubuntu16.04密码正确 进不去桌面系统(已测试恢复正常)

热门文章

  1. C语言高速入门系列(五)
  2. 从0到1打造直播 App(直播流程介绍整理 &lt;mark&gt;&lt;转&gt;)
  3. PHP移动互联网开发笔记(5)——基础函数库
  4. Windows7系统下安装OpenSSL攻略
  5. 关于用WebView或手机浏览器打开连接问题
  6. 分布式ID解决方案
  7. Architectures for concurrent graphics processing operations
  8. js一些编写的函数
  9. css+html+js实现多级下拉和弹出菜单
  10. svn: is already a working copy for a different url 解决办法