原文: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图像乘法运算的更多相关文章

  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.29图像除法运算

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

  6. Win8Metro(C#)数字图像处理--2.26图像减法

    原文:Win8Metro(C#)数字图像处理--2.26图像减法  [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...

  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. 忙里偷闲( ˇˍˇ )闲里偷学【C语言篇】——(2)准备知识

    一.变量为什么必须初始化? 在回答这个问题之前,我们先来运行一段代码: #include <stdio.h> int main(){ int i; printf("i=%d\n& ...

  2. Android自定义控件View(二)继承控件

    在前一篇博客中学习了Android自定义控件View的流程步骤和注意点,不了解的童鞋可以参考Android自定义控件View(一).这一节开始学习自定义控件View(二)之继承系统已有的控件.我们来自 ...

  3. [TFS4]TFS git地址,分支概念

    1)上传本地代码到TFS a.Generate Git Credentials,即创建git账户密码 b)上传本地代码 git add *git commit -m "纳入管理" ...

  4. 理解Erlang/OTP Supervisor

    http://www.cnblogs.com/me-sa/archive/2012/01/10/erlang0030.html Supervisors are used to build an hie ...

  5. 关于iPhone开发的一些建议

    建议 以后的应用程序,都使用AutoLayout, 不要再用绝对定位CGReck. 使用类似网页的方式来设计界面. 设计师好,程序员也好,尽量使用点这个单位进行思考,而不要使用像素.比如,你需要做44 ...

  6. 【29.89%】【codeforces 734D】Anton and Chess

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. com.sun.mirror的jar包

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/sinat_36246371/article/details/53170166 <Java編程思 ...

  8. Spring MVC的RequestContextHolder使用误区 good

    JShop简介:jshop是一套使用Java语言开发的B2C网店系统,致力于为个人和中小企业提供免费.好用的网店系统. 项目主页:http://git.oschina.net/dinguangx/js ...

  9. 从vue1迁移到vue2踩到的两个坑

    先说第一个,在vue1中用v-for的时候,习惯性用$index和$key来取键.今天迁移到vue2之前,也知道vue2里不能这样用了,结果还是出问题了, 数据渲染不出来. <li v-for= ...

  10. 我已经写了DAL层的代码生成器

    (1)创建您自己的解决方案 文件夹结构如以下: (2)编写代码: (要使用数据库 建议创建随意数据库就可以) 创建配置文件App.config代码例如以下: <?xml version=&quo ...