原文: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. signed 与 unsigned 有符号和无符号数

    unsigned int a = 0; unsigned int b = -1; // b 为 0xffffffff unsigned int c = a - 1; // c 为 0xffffffff

  2. windows下 管理员身份启动java进程

    http://blog.csdn.net/zhuyijian135757/article/details/38234757

  3. 辛星浅析yaf框架中的类的自己主动载入问题

    因为公司非常多项目都是基于yaf的,而非常多刚接触yaf的朋友问的第一个问题就是:yaf的自己主动载入是依照什么规则来的. 鉴于此.于是我特别开了一篇博文来记录一下. 首先在yaf中.models文件 ...

  4. 通过binlog日志统计dml语句,找出操作频繁的表

    mysqlbinlog --no-defaults --base64-output=decode-rows -v -v mysql-bin.000002 |awk '/###/{if($0~/UPDA ...

  5. Windows下启动ActiveMq端口被占用的解决办法

    cd /D E:\RuntimeSoft\apache-activemq-5.11.0\binactivemq.bat start结果提示:端口号被占用. Windows下查看端口号被占用开始--运行 ...

  6. python 单向循环列表

    # -*- coding: utf-8 -*- # @author: Tele # @Time : 2019/04/23 下午 6:54 # 单向循环列表 # 单向循环列表与单向列表的不同之处在于最后 ...

  7. cxf整合spring发布rest服务 httpclient访问服务

    1.创建maven web项目并添加依赖 pom.xml <properties> <webVersion>3.0</webVersion> <cxf.ver ...

  8. python3第一天学习(数据类型)

    参考blog地址:http://www.cnblogs.com/wupeiqi/articles/5444685.html,然后根据上面知识点练习并总结. 一.数字(int) 1.数字类型说明   在 ...

  9. 【28.57%】【codeforces 711E】ZS and The Birthday Paradox

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  10. C# 从零开始写 SharpDx 应用 控制台创建 Sharpdx 窗口

    原文:C# 从零开始写 SharpDx 应用 控制台创建 Sharpdx 窗口 版权声明:博客已迁移到 http://lindexi.gitee.io 欢迎访问.如果当前博客图片看不到,请到 http ...