博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Win8Metro(C#)数字图像处理--2.3图像反色
阅读量:6929 次
发布时间:2019-06-27

本文共 805 字,大约阅读时间需要 2 分钟。

原文:

[函数名称]

图像反色函数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;

           }  

       }

 

你可能感兴趣的文章
字符串相似度算法 递归与动态规划求解分析
查看>>
同步博客到CSDN
查看>>
VMware vSphere 服务器虚拟化之二十八 桌面虚拟化之安装View传输服务器
查看>>
用友CDM系统,将货位间商品移库单(一步)修改为内调出入库单(一步)方法使用...
查看>>
(Problem 14)Longest Collatz sequence
查看>>
Oracle中 Package与Package body的介绍
查看>>
解决设置redmineblacklog的按钮无效问题
查看>>
为阿里云存储开发的PHP PEAR 包:Services_Aliyun_OSS
查看>>
2013人人网校园招聘笔试题
查看>>
SqlServer基础:Bit类型
查看>>
挖财_百度百科
查看>>
MySql 日期格式化函数date_format()
查看>>
as3中使用stage ,root ,this 区别详解
查看>>
2013年第42周二明智行动的艺术
查看>>
如何订阅Linux相关的邮件列表
查看>>
8086汇编语言(1)虚拟机安装ms-dos 7.1
查看>>
mysqld守护进程
查看>>
2d网络游戏的延迟补偿(Lag compensation with networked 2D games)
查看>>
shell 之for [转]
查看>>
[Windows核心编程]32bit程序在64bit操作系统下处理重定向细节[1]
查看>>