原文:Win8Metro(C#)数字图像处理--2.27图像加法运算



[函数名称]

图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap addSrc)

[函数代码]

        /// <summary>

        /// Add procession of two images(Both of them should be in same size).

        /// </summary>

        /// <param name="src">The first source image.</param>

        /// <param name="addSrc">The second source iamge.</param>

        /// <returns></returns>

        public static WriteableBitmap AddProcess(WriteableBitmap src,WriteableBitmap addSrc)////27图像加法 

        {

            if (src != null)

            {

                int w = src.PixelWidth;

                int h = src.PixelHeight;

                WriteableBitmap addImage = new WriteableBitmap(w, h);

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

                byte[] addTemp = addSrc.PixelBuffer.ToArray();

                byte[] dst = new byte[w * h * 4];

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

                for (int i = 0; i < w; i++)

                {

                    for (int j = 0; j < h; j++)

                    {

                        b = temp[i * 4 + (h - 1 - j) * w * 4] + addTemp[i * 4 + (h - 1 - j) * w * 4];

                        g = temp[i * 4 + 1 + (h - 1 - j) * w * 4] + addTemp[i * 4 + 1 + (h - 1 - j) * w * 4];

                        r = temp[i * 4 + 2 + (h - 1 - j) * w * 4] + addTemp[i * 4 + 2 + (h - 1 - j) * w * 4];

                        dst[i * 4 + j * w * 4] = (byte)(b > 0 ? (b < 255 ? b : 255) : 0);

                        dst[i * 4 + 1 + j * w * 4] = (byte)(g > 0 ? (g < 255 ? g : 255) : 0);

                        dst[i * 4 + 2 + j * w * 4] = (byte)(r > 0 ? (r < 255 ? r : 255) : 0);

                        dst[i * 4 + 3 + j * w * 4] = 0;

                        b = 0; g = 0; r = 0;

                    }

                }

                Stream sTemp = addImage.PixelBuffer.AsStream();

                sTemp.Seek(0, SeekOrigin.Begin);

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

                return addImage;

            }

            else

            {

                return null;

            }      

        }

Win8Metro(C#)数字图像处理--2.27图像加法运算的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.29图像除法运算

    原文:Win8Metro(C#)数字图像处理--2.29图像除法运算  [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...

  2. Win8Metro(C#)数字图像处理--2.3图像反色

    原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明]     反色公式如下: ...

  3. Win8Metro(C#)数字图像处理--2.33图像非线性变换

    原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换  [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...

  4. Win8Metro(C#)数字图像处理--2.32图像曝光算法

    原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法  [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...

  5. Win8Metro(C#)数字图像处理--2.28图像乘法运算

    原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算  [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...

  6. Win8Metro(C#)数字图像处理--2.26图像减法

    原文:Win8Metro(C#)数字图像处理--2.26图像减法  [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...

  7. Win8Metro(C#)数字图像处理--2.19图像水平镜像

    原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像  [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码]      ...

  8. Win8Metro(C#)数字图像处理--2.20图像垂直镜像

    原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像  [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码]      ...

  9. Win8Metro(C#)数字图像处理--2.18图像平移变换

    原文:Win8Metro(C#)数字图像处理--2.18图像平移变换  [函数名称] 图像平移变换函数TranslationProcess(WriteableBitmap src,int x,in ...

随机推荐

  1. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(5)有趣的指针

    一.指针是C语言的灵魂 # include <stdio.h> int main(){ int *p; //p是变量名,int *表示p变量存放的是int类型变量的地址,p是一个指针变量 ...

  2. 主从同步设置的重要参数log_slave_updates

    说明:最近部署了mysql的集群环境,详细如下M01和M02为主主复制,M01和R01为主从复制:在测试的过程中发现了以下问题: 1.M01和M02的主主复制是没有问题的(从M01写入数据能同步到M0 ...

  3. JM-1 手机网站开发测试环境搭建

    JM-1 手机网站开发测试环境搭建 一.总结 一句话总结:WEB服务器环境可实现局域网内轻松访问.360wifi可以实现局域网. 二.微网站开发环境: 1.把微网站放到本机wamp环境下,用pc浏览器 ...

  4. thinkphp5开发规范(加强复习之前的)

    thinkphp5开发规范(加强复习之前的) 一.总结 一句话总结:和类相关的采用驼峰命名法:变量,函数,类,方法,属性采用驼峰命名发:数据库及文件及配置参数是小写字母加下划:常量大写加下划线 1.T ...

  5. 毕设三: spark与phoenix集成插入数据/解析json数组

    需求:将前些日子采集的评论存储到hbase中 思路: 先用fastjson解析评论,然后构造rdd,最后使用spark与phoenix交互,把数据存储到hbase中 部分数据: [ { "r ...

  6. 关系型数据库工作原理-快速缓存(翻译自Coding-Geek文章)

    本文翻译自Coding-Geek文章:< How does a relational database work>. 原文链接:http://coding-geek.com/how-dat ...

  7. _Decoder_Interface_init xxxxxx in amrFileCodec.o

    Undefined symbols for architecture arm64: "_Decoder_Interface_init", referenced from: Deco ...

  8. Python 工具类与工具函数 —— pair

    def pair(lis): n = len(lis) for i in range(n): for j in range(i+1, n): yield lis[i], lis[j] 这样在调用端,访 ...

  9. MapReduce自定义InputFormat,RecordReader

    MapReduce默认的InputFormat是TextInputFormat,且key是偏移量,value是文本,自定义InputFormat需要实现FileInputFormat,并重写creat ...

  10. java获取本机IP地址,非127.0.0.1

    综合了网上找的代码,整理的,Windows和Linux都可以用. private static String getHostIp(){ try{ Enumeration<NetworkInter ...