Win8Metro(C#)数字图像处理--2.28图像乘法运算
原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算
[函数名称]
图像乘法函数MultiplicationProcess(WriteableBitmap src, WriteableBitmap mulSrc)
[函数代码]
/// <summary>
/// Multiplication of two images(Both of them should be in same size).
/// </summary>
/// <param name="src">The first source image.</param>
/// <param name="maskSrc">The second source image(It is an mask that each pixel of it is 0 or 1).</param>
/// <returns></returns>
public static WriteableBitmap MultiplicationProcess(WriteableBitmap src, WriteableBitmap maskSrc)////28图像乘法
{
if (src != null)
{
int w = src.PixelWidth;
int h = src.PixelHeight;
WriteableBitmap mulImage = new WriteableBitmap(w, h);
byte[] temp = src.PixelBuffer.ToArray();
byte[] mulTemp = maskSrc.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] * mulTemp[i * 4 + (h - 1 - j) * w * 4];
g = temp[i * 4 + 1 + (h - 1 - j) * w * 4] * mulTemp[i * 4 + 1 + (h - 1 - j) * w * 4];
r = temp[i * 4 + 2 + (h - 1 - j) * w * 4] * mulTemp[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 = mulImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(dst, 0, w * 4 * h);
return mulImage;
}
else
{
return null;
}
}
Win8Metro(C#)数字图像处理--2.28图像乘法运算的更多相关文章
- 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.29图像除法运算
原文:Win8Metro(C#)数字图像处理--2.29图像除法运算 [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...
- Win8Metro(C#)数字图像处理--2.26图像减法
原文:Win8Metro(C#)数字图像处理--2.26图像减法 [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...
- 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 ...
随机推荐
- 小强的HTML5移动开发之路(45)——汇率计算器【1】
这两天看了<PhoneGap实战>上面有一个汇率计算器的例子,个人觉得比较好,就拿出来和大家分享一下,在接下来的几篇文章中我们来一起完成这个PhoneGap + Jquery mobile ...
- dbvisualizer 使用笔记
快捷键:CTRL+SHIFT+F 格式化选中的sql语句 导入导出数据操作 导入: 1.将Exel文件另存为csv文件 2.在dbvisualizer中点击开发数据库,如test_dev,然后在te ...
- [Django] Building the rest API
Install the rest api framework: pip install djangorestfamework In settings.py: INSTALLED_APPS = [ 'd ...
- C#-numericUpDown-数字选择---ShinePans
program.cs using System; using System.Collections.Generic; using System.Linq; using System.Windows.F ...
- iPad和iPhone开发的异同
niPad和iPhone开发的异同 niPad简介 n什么是iPad p一款苹果公司于2010年发布的平板电脑 p定位介于苹果的智能手机iPhone和笔记本电脑产品之间 p跟iPhone一样,搭载 ...
- Role-based access control modeling and auditing system
A role-based access control (RBAC) modeling and auditing system is described that enables a user to ...
- 关系型数据库工作原理-快速缓存(翻译自Coding-Geek文章)
本文翻译自Coding-Geek文章:< How does a relational database work>. 原文链接:http://coding-geek.com/how-dat ...
- 免费的 C/C++ 编译&解释 器列表
摘自<C++编程网>,详细介绍请参考http://www.cpp-prog.com/2009/0520/118.html MicrosoftVisual C++ 2008 Express ...
- 利用marquee对html页面文本滚动
<marquee direction="up" style="width:200px;height:80px; " scrolldelay="3 ...
- 【rlz000】字串找数
Time Limit: 3 second Memory Limit: 2 MB 问题描述 输入一个字符串,内有数字和非数字字符.如A123X456Y7A,302ATB567BC,统计共有多少个整数, ...