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 ...
随机推荐
- 【codeforces 757C】Felicity is Coming!
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 简单实现的Servlet文件上传,并显示
http://my.oschina.net/Barudisshu/blog/157481
- [.NET Core 24]把project.json迁移到.csproj
链接:https://blog.jetbrains.com/dotnet/2017/04/04/rider-eap-update-csproj-based-net-core-support-migra ...
- 为何放弃 C++ 的工作(开发慢,难度高。完全不适应互联网的快速迭代的思想)
happypeter,2015年1月9日 昨天进燕山大学编程爱好者 QQ 群,看到有很多同学在学 C++ ,我当然是不喜欢了,因为我是做 Web 开发的嘛.所以怀着猥琐的心情,今天写篇傻傻的文章,来黑 ...
- iOS CALayer使用
CALayer使用 iOS的设备中,我们之所以能看到各种各样的控件.文字.图片,都是Core Animation框架的功劳.它通过图层的合成,最终显示在屏幕上.而今天这篇文章讲的就是Core Anim ...
- create-react-app 支持 装饰器 decorator
网上常见方法全是安装 babel-plugin-transform-decorators-legacy 然后添加babel配置的, 实际情况是最新版本的create-react-app 生成的项目已经 ...
- HTML5 的成长之路
html5历史 w3c从2008年提出html5的概念,目前html5的版本已经趋于稳定,也逐步得到了业界的认可和接受. 以前我们有一个疑问,HTML5与Flash究竟谁将在移动互联网时代称霸市场?这 ...
- vue router 传递参数
vue-router 传参的方式 query 和params query 类似于get请求的传参方法 就是 ? 这种形式的 https://i.cnblogs.com/EditPosts.aspx?o ...
- Xbin-Store(分布式商城)项目所用Linux服务系列 FastDFS安装(五)
系列 Xbin-Store(分布式商城)项目所用Linux服务系列 MySQL安装(一) Xbin-Store(分布式商城)项目所用Linux服务系列 Redis集群安装(二) Xbin-Store( ...
- VS2015编译环境下CUDA安装配置
CUDA下载 CUDA是NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题,CUDA只支持NVIDIA自家的显卡,过旧的版本型号也不被支持. 下载地址:https://devel ...