原文: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. PHP移动互联网开发笔记(6)——文件的上传下载

    一.文件的上传 1.客户端设置: (1).在<form>标签中将enctype和method两个属性指明相应的值. Enctype="multipart/form-data&qu ...

  2. 【a502】符号三角形问题

    Time Limit: 1 second Memory Limit: 32 MB [问题描述] 在一般情况下,符号三角形的第一行有n个符号.按照2个同号的下面是"+"号,2个异号的 ...

  3. 【codeforces 604D】Moodular Arithmetic

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 检索 04 --Stack栈 Queue队列 Hashtable哈希表

    //Stack 先进后出 没有索引 Stack st = new Stack(); st.Push(12); st.Push(11); st.Push(22); st.Push(34); st.Pus ...

  5. POJ 2418-Hardwood Species(map)

    Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 18770   Accepted: 740 ...

  6. maven hadoop 3.x HADOOP_HOME and hadoop.home.dir are unset Not implemented by the WebHdfsFileSystem FileSystem implementation

    具体异常如下: 解决方案: 删除pom文件中的hadoop-core的依赖,原因:hadoop-core是1.x的产物,在2.x之后已经被hadoop-common取代,我配置的时候同时使用了这两个依 ...

  7. Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/vm10-0-0-19

    输入:service mysqld start 报错: Starting MySQL.. ERROR! The server quit without updating PID file (/usr/ ...

  8. visio(2013)绘图工具的使用

    1. 链接线 ⇒ 直线 visio2010中如何使画出来的连接线为直线 [设计面板] ⇒ 在最右端将[链接线]设置为直线: 2. 连接线交叉而不产生交叉桥(弯曲) visio2013画图时两条直线交叉 ...

  9. 《modern operating system》 chapter 5 Input and output 注意事项

    Input / Output It should also provide an interface between the devices and the rest of the system th ...

  10. Android中的事件处理研究

    处理用户界面事件Handling UI Events 在Android上,不止一个途径来侦听用户和应用程序之间交互的事件.对于用户界面里的事件,侦听方法就是从与用户交互的特定视图对象截获这些事件.视图 ...