Win8Metro(C#)数字图像处理--2.26图像减法
原文: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图像减法的更多相关文章
- Win8Metro(C#)数字图像处理--2.3图像反色
原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下: ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.32图像曝光算法
原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法 [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...
- Win8Metro(C#)数字图像处理--2.27图像加法运算
原文:Win8Metro(C#)数字图像处理--2.27图像加法运算 [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...
- Win8Metro(C#)数字图像处理--2.28图像乘法运算
原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算 [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...
- Win8Metro(C#)数字图像处理--2.29图像除法运算
原文:Win8Metro(C#)数字图像处理--2.29图像除法运算 [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...
- Win8Metro(C#)数字图像处理--2.19图像水平镜像
原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像 [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码] ...
- Win8Metro(C#)数字图像处理--2.20图像垂直镜像
原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像 [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码] ...
- Win8Metro(C#)数字图像处理--2.18图像平移变换
原文:Win8Metro(C#)数字图像处理--2.18图像平移变换 [函数名称] 图像平移变换函数TranslationProcess(WriteableBitmap src,int x,in ...
随机推荐
- JBoss AS 7之初步了解(The Return Of The King)
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvam9obl9mX2xhdQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- GlobalMemoryStatus 和 GlobalMemoryStatusEx
1.获取系统内存信息有2个api,分别是GlobalMemoryStatus和GlobalMemoryStatusEx.GlobalMemoryStatus函数可以在C语言里直接调用,但是Global ...
- [NPM] Make npm scripts cross-environment friendly
Unfortunately not all shell commands work across various environments. Two main techniques to suppor ...
- Android Studio 连接自己搭建的server 须要admin 的帐号的问题 SSH Password Login,please enter password for user git@git.
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...
- erlang分布式入门(一)-ping pong
erlang分布式入门(一)-ping pong 测试环境和http://willvvv.iteye.com/blog/1523918 一样,192.168.0.182(centos-182)和192 ...
- Linux中vim编辑器莫名下方出现H的问题
在使用vim编辑文件的时候,不知道自己是按了哪个快捷键,导致了,每次编辑文件时,下方命令行出现数字+H的格式命令,使得整个文件没法编辑,强制退出后进入不能解决问题,各种文件的编辑都不行,找不出原因,最 ...
- XMPP之安装mySQL--Mac OS(一)
come from:http://www.cnblogs.com/xiaodao/archive/2013/04/04/2999426.html 一.安装 到MySQL官网上http://dev.my ...
- 【codeforces 776D】The Door Problem
[题目链接]:http://codeforces.com/contest/776/problem/D [题意] 每个门严格由两个开关控制; 按一下开关,这个开关所控制的门都会改变状态; 问你能不能使所 ...
- js声明json数据,打印json数据,遍历json数据,转换json数据为数组
1.js声明json数据: 2.打印json数据: 3.遍历json数据: 4.转换json数据为数组; //声明JSON var json = {}; json.a = 1; //第一种赋值方式(仿 ...
- 解决eclipse 保存卡顿的问题
开发十年,就只剩下这套Java开发体系了 >>> eclipse 如果启动慢,还可以接收. 可是如果是 保存的时候卡顿, 有时候会 卡顿 3秒-5 秒的,感觉到写代码特别的不顺畅 ...