原文:Win8Metro(C#)数字图像处理--2.3图像反色


[函数名称]

图像反色函数ContraryProcess(WriteableBitmap
src)

[算法说明]

    反色公式如下:       P'(x,y) = 255 - P(x,y);

    P'(x,y)为反色后的像素值,P(x,y)是原始像素值。

[函数代码]

       ///<summary>

       ///
Contrary process.

       ///</summary>

       ///<param
name="src">Source image.</param>

       ///<returns></returns>

 publicstaticWriteableBitmap
ContraryProcess(WriteableBitmap src)////3反色处理

       {

           if(src!=null
)

           {

           int
w = src.PixelWidth;

           int
h = src.PixelHeight;

           WriteableBitmap
contraryImage =newWriteableBitmap(w,
h);

           byte[]
temp = src.PixelBuffer.ToArray();

           for
(int i = 0; i < temp.Length; i += 4)

           {

               temp[i] = (byte)(255
- temp[i]);

               temp[i + 1] = (byte)(255
- temp[i + 1]);

               temp[i + 2] = (byte)(255
- temp[i + 2]);

           }

           Stream
sTemp = contraryImage.PixelBuffer.AsStream();

           sTemp.Seek(0,SeekOrigin.Begin);

           sTemp.Write(temp, 0, w * 4 * h);

           return
contraryImage;

           }       

           else

           {

               returnnull;

           }  

       }


 

Win8Metro(C#)数字图像处理--2.3图像反色的更多相关文章

  1. Win8Metro(C#)数字图像处理--2.33图像非线性变换

    原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换  [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...

  2. Win8Metro(C#)数字图像处理--2.32图像曝光算法

    原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法  [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...

  3. Win8Metro(C#)数字图像处理--2.27图像加法运算

    原文:Win8Metro(C#)数字图像处理--2.27图像加法运算  [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...

  4. Win8Metro(C#)数字图像处理--2.28图像乘法运算

    原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算  [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...

  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. [Angular] NgRx/effect, why to use it?

    See the current implementaion of code, we have a smart component, and inside the smart component we ...

  2. iOS 下APNS推送处理函数具体解释

    相比起Android,iOS在推送方面无疑惯例得更好.APNS(Apple Push Notification Service)是苹果公司提供的消息推送服务.其原理就是.第三方应用将要推送给用户的信息 ...

  3. 【a703】求逆序对(线段树的解法)

    Time Limit: 10 second Memory Limit: 2 MB 问题描述 给定一个序列a1,a2...an.如果存在i小于j 并且ai大于aj,那么我们称之为逆序对,求给定序列中逆序 ...

  4. jQuery+ localStorage 实现一个简易的计时器

    原型 图片发自简书App 需求1.关闭浏览器时时间继续运行2.刷新时保持当前状态3.结束时间保存在客户端 <div class="wrapper"> <div c ...

  5. 【t060】可怜的波特

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 哈里波特在姨夫家遭受非人待遇,他被迫做很多事.有一次,姨夫有给了他一大堆家务.哈里知道每件做完家务的时 ...

  6. 手动安装huson插件的做法

    作者:朱金灿 来源:http://blog.csdn.net/clever101 首先到jenkins-ci.org下载插件,地址为:http://updates.jenkins-ci.org/dow ...

  7. 数据可视化 —— 数据流图(Data Flow Diagram)

    数据流图(Data Flow Diagram):简称 DFD,它从数据传递和加工角度,以图形方式来表达系统的逻辑功能.数据在系统内部的逻辑流向和逻辑变换过程,是结构化系统分析方法的主要表达工具及用于表 ...

  8. 欢迎来到Swift天地(Welcome to Swift)

    期待已久的WWDC真的是不管是什么硬件更新,没有太多的开发者,本次会议是还是很有亮点.水果给我们带来了一种新的语言Swift.种无比简洁高效的语言,并且新的 Swift 语言依然会和 C 与 Obje ...

  9. Bit error testing and training in double data rate (ddr) memory system

    DDR PHY interface bit error testing and training is provided for Double Data Rate memory systems. An ...

  10. Qt中(图片)资源的三种使用方式

    Qt中使用图片资源的方法有很多种,以前我一直分不清各种之间的区别和Qt相应的处理机制,后来遇到一些实际的问题,然后再加上查阅源码和资料,总算弄明白一些事情,但是本文仅仅是个人理解,如有错误之处请告诉我 ...