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 ...
随机推荐
- 配置Apache支持PHP5
环境:window 7.Apache/2.2.19 (Win32) PHP/5.2.9-1 1.配置server名称 将里面的 #ServerName localhost:80 凝视去掉就可以. 又一 ...
- 蓝牙简单配对(Simple Pairing)协议及代码流程简述
kangear注: 文章转自:http://blog.csdn.net/myxmu/article/details/12217135 原文把图给搞丢了.可是文章太好了,这个时候我就发挥多年的Googl ...
- AndroidStudio如何配置NDK/JNI开发环境
参考文章: http://www.th7.cn/Program/Android/201509/550864.shtml http://www.open-open.com/lib/view/open14 ...
- CSDN code使用教程之git使用方法具体解释
首先须要下载GITclient.http://git-scm.com/downloads. . . 然后再code.csdn.net上面创建一个项目,假设 你的项目已经存在.那么请建立项目 ...
- [NPM] Use package.json variables in npm scripts
In this lesson we will show that you can leverage values that you already have provided in your pack ...
- [SVG] Combine Multiple SVGs into an SVG Sprite
In this lesson, we’ll explore the process of combining all of your SVG icons into one SVG sprite, to ...
- color2gray 的实现
无论是 rgb 还是 yuv 等三通道的颜色空间中的像素点,将其转换为单通道(pixel_depth=255.)中的像素,一般情况下都是采用的对原始颜色空间的 3 通道的像素点线性组合而得到单通道的像 ...
- KVO的使用(1)
1.在某个类中添加下面方法: -(void)viewWillAppear:(BOOL)animated{ [[NSNotificationCenter defaultCenter] addObserv ...
- 一道SQL题考你数据库的使用能力
题目:数据库中存在例如以下数据,求用户终于剩余金额. 用户 类型 金额 A 存入 100 A 存入 200 A 取出 100 A 取出 200 A 存入 300 A 取出 300 本人Oracle接触 ...
- 【P084】立体图
Time Limit: 1 second Memory Limit: 50 MB [问题描述] 小渊是个聪明的孩子,他经常会给周围的小朋友们讲些自己认为有趣的内容.最近,他准备给小朋友们讲解立体图,请 ...