Win8 Metro(C#)数字图像处理--2.47人脸红眼去除算法
2024-10-01 01:10:07
原文: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;
}
}
[图像效果]
最新文章
- ecshop 多表删除
- some code of c
- Zepto 使用过程中遇到的问题总结
- Ghost博客安装
- Android应用反破解的思路
- BigDecimal类的加减乘除
- 浅谈压缩感知(三十):压缩感知重构算法之L1最小二乘
- ARCGIS10.1 GeoDatabase深入理解:客户端连接与退出地理数据库时系统表的初始化
- c# 并行运算
- ios-XML文档解析之SAX解析
- LoadRunner 录制cas 登陆脚本
- 摸索出来的chrom调试前后台数据(Java&;&;Ajax)交互的方法分享一下咯!!!
- js的内置对象
- python函数调用之自我调用与C++比较
- 深度召回模型在QQ看点推荐中的应用实践
- jdbc.properties+web.xml
- ABAP接口之Http发送json报文
- Confluence 6 在初始化配置时候的问题
- Cocos Creator两个类相互引用(调用)
- Ubuntu16.04密码正确 进不去桌面系统(已测试恢复正常)
热门文章
- C语言高速入门系列(五)
- 从0到1打造直播 App(直播流程介绍整理 <;mark>;<;转>;)
- PHP移动互联网开发笔记(5)——基础函数库
- Windows7系统下安装OpenSSL攻略
- 关于用WebView或手机浏览器打开连接问题
- 分布式ID解决方案
- Architectures for concurrent graphics processing operations
- js一些编写的函数
- css+html+js实现多级下拉和弹出菜单
- svn: is already a working copy for a different url 解决办法