原文: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. [CSS] Nest a grid within a grid

    A grid item can also be a grid container! Let’s see how to specify a grid within a grid.

  2. SVN入门图解教程(超详细)

    SVN入门图解教程(超详细) 一.总结 一句话总结: 二.SVN入门教程 1. 什么是SVN SVN全名Subversion,即版本控制系统.SVN与CVS一样,是一个跨平台的软件,支持大多数常见的操 ...

  3. 【t062】最厉害的机器人

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] [背景] Wind设计了很多机器人.但是它们都认为自己是最强的,于是,一场比赛开始了~ [问题描述] ...

  4. 【a501】算24点

    Time Limit: 1 second Memory Limit: 32 MB [问题描述] 几十年前全世界就浒一种数字游戏,至今仍有人乐此不疲.在中国我们把这种游戏称为"算24点&quo ...

  5. 【BZOJ 1016】 [JSOI2008]最小生成树计数(matrix-tree定理做法)

    [题目链接]:http://www.lydsy.com/JudgeOnline/problem.php?id=1016 [题意] [题解] /* 接上一篇文章; 这里用matrix-tree定理搞最小 ...

  6. 关于生命周期里执行setState

    React里生命周期的哪些方法里可以执行setState,这对于很多使用React很长时间的开发都是个迷惑的问题. 先看一下完整的生命周期. 再看两篇文章 React componentDidUpda ...

  7. DEA上安装和使用checkstyle,findbugs,visualVM,PMD插件

    ##安装插件步骤: 1.打开settings 2.选择plugins 3.点击"Browse repositories" 4.搜索对应内插件,点击"install&quo ...

  8. webpack单独构建scss文件与.vue组件里构建scss的一个坑

    在入口main.js里构建scss是通过引入模块的方式 import './assets/_reset.scss'; import './assets/_flex.scss'; import './a ...

  9. 【45.61%】【codeforces 701D】As Fast As Possible

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  10. Cocos2d-X中国象棋的发展《五岁以下儿童》摆棋

    在博客上,以实现创建的游戏场景.而一些button,因为button落实到事件作出详细答复,需要使用一些功能摆棋.为此我特意button上的背面的具体实施, 在摆棋前先理清一下摆棋的思路: 1.创建一 ...