原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法



[函数名称]

图像曝光函数ExposureProcess(WriteableBitmap src,int exposureValue) 

[函数代码]

        /// <summary>

        /// Exposure process.

        /// </summary>

        /// <param name="src">Source image.</param>

        /// <param name="exposureValue">To adjust exposure lavel, from 0 to 255.</param>

        /// <returns></returns>

        public static WriteableBitmap ExposureProcess(WriteableBitmap src,int exposureValue)////35图像曝光

        {

            if (src != null)

            {

                int w = src.PixelWidth;

                int h = src.PixelHeight;

                WriteableBitmap exposureImage = new WriteableBitmap(w, h);

                int r=0,g=0,b=0;

                byte[] temp = src.PixelBuffer.ToArray();

                for (int i = 0; i < temp.Length; i += 4)

                {

                    byte tempByte = (byte)((int)(temp[i] * 0.114 + temp[i + 1] * 0.587 + temp[i + 2] * 0.299));

                    b = temp[i];

                    g = temp[i + 1];

                    r = temp[i + 2];

                    if (tempByte < 128)

                    {

                        temp[i] = (byte)(255 - b);

                        temp[i + 1] = (byte)(255 - g);

                        temp[i + 2] = (byte)(255 - r);

                    }

                }

                Stream sTemp = exposureImage.PixelBuffer.AsStream();

                sTemp.Seek(0, SeekOrigin.Begin);

                sTemp.Write(temp, 0, w * 4 * h);

                return exposureImage;

            }

            else

            {

                return null;

            }         

        }

[图像效果]

最新文章

  1. Salesforce学习笔记(一)
  2. Router的创建者——RouteBuilder
  3. 在 SQL Server 中的网络数据库文件的支持说明
  4. Jplayer(转)
  5. Webbrowser中模拟连接点击(非鼠标模拟)
  6. EJB通过ANT提高EJB应用程序的开发效率、无状态发展本地接口bean、开发状态bean
  7. log4j2
  8. 如何利用Plxmon工具进行在线烧录PCI卡的EEPROM
  9. IDEA安装教程
  10. anaconda常用操作汇总
  11. 模拟位置 定位 钉钉打卡 运动轨迹 MD
  12. TP方法中打印地址栏中所有的参数:
  13. 如何判断win10 和office的版本
  14. leetcode15
  15. python成长之路六-函数的初识
  16. caffe的model参数解析numpy多维数组的存取
  17. GRUB2 命令行使用笔记
  18. redis-storage介绍[转]
  19. numpy 初识(三)
  20. ShowDoc 搭建 (未成功....)

热门文章

  1. [ES6] Use ES6 Proxies
  2. QQ欢乐斗地主心得体会 (三):高倍场攻略
  3. mui列表跳转到详情页优化方案
  4. sql中group by用来干嘛的
  5. iOS项目中所有icon的尺寸以及命名
  6. 关于在方法里面使用泛型public static &lt;T&gt; T
  7. [GeekBand] C++ 内存分布—— new和delete重载的实现及分析
  8. 微信小程序要调数据 微信小程序 for 循环详解
  9. 【26.67%】【codeforces 596C】Wilbur and Points
  10. linux下jar包的生存与开机自动启动