原文: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. log4erl API

    https://github.com/ahmednawras/log4erl/blob/master/API.txt NOTE:=====Please be informed that the API ...

  2. 过滤Filter推断用户是否登录

    WEB.XML <!-- 用户session的 键 sessionKEY --> <context-param> <param-name>userSessionKe ...

  3. Winfrom 重新登录

    private void ReLogin_Click(object sender, EventArgs e) { ///实例化一个进程 Process process = new Process(); ...

  4. CSS布局--左侧自适应母元素高度

    平常项目中经常会遇到有左侧导航菜单的高度不固定,需要与母元素或右侧元素等高的情况,以前就自以为是的使用js来设置,不仅不方便还会出现各种bug,后来就突然想到了一个好方法.有可能这方法已经被其他人用烂 ...

  5. boost::any在降低模块之间耦合性的应用

    作者:朱金灿 来源:http://blog.csdn.net/clever101 在开发大型系统中,遵循这样一个原则:模块之间低耦合,模块内高内聚.比如系统中模块有界面模块和算法模块两种,一般是界面模 ...

  6. 【Sliding Window】单调队列

    题目描述 给你一个长度为 N 的数组,一个长为 K 的滑动的窗体从最左移至最右端,你只能见到窗口的 K 个整数,每次窗体向右移动一位,如下表:

  7. request.getSession().getServletContext().getRealPath()的一些坑

    今天是学校机房的服务器上对之前的一个网站升级时发现了一个bug,我自己的机器上用的tomcat8,机房上是tomcat7,结果一运行就开始报找不到文件,最后发现是文件分隔符的问题 原来在代码中涉及到路 ...

  8. vue 使用jquery (全局)

    1 全局配置jquery , 个人习惯 , 离不开jquery了 然后重启项目 就 完事

  9. numpy 维度与轴的问题

    0. 多维数组的显示问题 >> X = np.reshape(np.arange(24), (2, 3, 4)) # 也即 2 行 3 列的 4 个平面(plane) >> X ...

  10. HPC —— 高性能计算

    CUDA,目前只有 NVIDIA 支持: OpenCL,CUDA Tesla 卡很贵: 1. 术语及概念 SMP:"对称多处理"(Symmetrical Multi-Process ...