博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Win8 Metro(C#)数字图像处理--2.47人脸红眼去除算法
阅读量:6648 次
发布时间:2019-06-25

本文共 1514 字,大约阅读时间需要 5 分钟。

原文:



[函数名称]

  红眼去除     RedeyeRemoveProcess(WriteableBitmap src)

///         /// Redeye remove Process.        ///         /// The source image.        /// 
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; } }

[图像效果]

你可能感兴趣的文章
如何使用PhoneGap程序将AdMob广告嵌入到你的HTML5 iOS游戏中
查看>>
2014工作总结
查看>>
gluster分布式存储总结与实践
查看>>
我的友情链接
查看>>
Python爬虫爬数据写入到EXCEL中
查看>>
我的友情链接
查看>>
nginx的web目录下处理中文文件和文件夹以及编码格式问题
查看>>
Linux下Tomcat重新启动
查看>>
oracle rac 监听配置
查看>>
网络***简单介绍
查看>>
代理模式与动态代理
查看>>
MySQL 5.7 开启binary log(binlog)及注意事项
查看>>
Linux crontab 任务误删恢复及备份步骤
查看>>
Tomcat集群---Cluster节点配置
查看>>
keepalive第二弹---构建轻量级的nginx高可用
查看>>
Mysql时间精度丢失问题
查看>>
MySQLSyntaxErrorException问题处理
查看>>
7_盒子模型.txt
查看>>
Linux 自动安装 pxe+kickstart
查看>>
TClientDataSet[13]: 过滤
查看>>