原文:Win8Metro(C#)数字图像处理--2.26图像减法



[函数名称]

图像减法函数SubtractionProcess(WriteableBitmap
src, WriteableBitmap
subSrc)

[算法说明]

图像减法就是将两幅图像对应像素值进行减法运算,这里要求两幅图像大小最好相同。

算法过程如下:

[函数代码]

///<summary>

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

///</summary>

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

///<param
name="subSrc">The second source image.</param>

///<returns></returns>

publicstaticWriteableBitmap
SubtractionProcess(WriteableBitmap src,WriteableBitmap
subSrc)////26图像减法

{

if
(src !=null)

{

int
w = src.PixelWidth;

int
h = src.PixelHeight;

WriteableBitmap
subImage =newWriteableBitmap(w,
h);

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

byte[]
subTemp = subSrc.PixelBuffer.ToArray();

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

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

{

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

{

dst[i * 4 + j * w * 4] = (byte)Math
.Abs(temp[i * 4 + (h - 1 - j) * w * 4] - subTemp[i * 4 + (h - 1 - j) * w * 4]);

dst[i * 4 + 1 + j * w * 4] = (byte)Math
.Abs(temp[i * 4 + 1 + (h - 1 - j) * w * 4] - subTemp[i * 4 + 1 + (h - 1 - j) * w * 4]);

dst[i * 4 + 2 + j * w * 4] = (byte)Math
.Abs(temp[i * 4 + 2 + (h - 1 - j) * w * 4] - subTemp[i * 4 + 2 + (h - 1 - j) * w * 4]);

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

}

}

Stream
sTemp = subImage.PixelBuffer.AsStream();

sTemp.Seek(0,
SeekOrigin.Begin);

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

return
subImage;

}

else

{

returnnull;

}

}

[图像效果]

Win8Metro(C#)数字图像处理--2.26图像减法的更多相关文章

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

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

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

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

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

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

  4. Win8Metro(C#)数字图像处理--2.27图像加法运算

    原文:Win8Metro(C#)数字图像处理--2.27图像加法运算  [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...

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

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

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

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

  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. [tmux] Share a tmux session for pair programming with ssh

    By using ssh, you can share a tmux session, making pair programming much easier. We'll learn how to ...

  2. 恩布900手机客服,安卓版本号Entboost Android 1.0 正式公布

    恩布900手机客服,安卓版本号Entboost Android 1.0正式公布,支持一行代码在安卓手机实如今线客服的功能,支持文本.表情,图片,语音和离线消息等. ENTBOOST是跨平台.跨应用的实 ...

  3. [DevExpress]DevExpress 中 汉化包 汉化方法

    第一步: 在Debug 下加入 zh-CN 汉化包(自行下载) 第二步: 在 Program.cs中加入下面代码 : System.Threading.Thread.CurrentThread.Cur ...

  4. 【codeforces 768A】Oath of the Night's Watch

    [题目链接]:http://codeforces.com/contest/768/problem/A [题意] 让你统计这样的数字x的个数; x要满足有严格比它小和严格比它大的数字; [题解] 排个序 ...

  5. Architectures for concurrent graphics processing operations

    BACKGROUND 1. Field The present invention generally relates to rendering two-dimension representatio ...

  6. 使用Ant包装时,包javax.servlet.http有没有搞错

    明确,出现此错误的原因是缺乏相应的jar包.详细原因因为servlet和JSP不是Java平台JavaSE(标准版)的一部分.而是Java EE(企业版)的一部分,因此,必须告知编译器servlet的 ...

  7. cordova通过指纹插件进行指纹验证

    原文:cordova通过指纹插件进行指纹验证 版权声明:本文为博主原创文章,转载须注明出处,博客地址:https://blog.csdn.net/wx13227855087 https://blog. ...

  8. Ubuntu server使用命令行上板VPNclient

    Ubuntu server使用命令行上板VPNclient VPN,虚拟专用网络,这个技术还是非常有用的.近期笔者參与的项目中就使用上了VPN,大概情况是这种.有两个开发团队,在异地,代码服务器在深圳 ...

  9. postman VS restlet client基本使用

    postman与restlet都是使用的google浏览器的插件(出不去自行解决,you get!),此两款软件的强大这里就不在赘述了,postman的网上说明很多,restlet的中文配置很少了.这 ...

  10. .net remoting 抛出异常

    原文:.net remoting 抛出异常 本文告诉大家如何在使用 .net remoting 的时候,抛出异常. 所有在远程软件运行的类,如果需要传输到本地,都需要继承 MarshalByRefOb ...