原文:Win8Metro(C#)数字图像处理--2.9图像均值滤波



[函数名称]

图像均值滤波函数MeanFilterProcess(WriteableBitmap
src)

[函数代码]

       ///<summary>

       ///
Mean filter process.

       ///</summary>

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

       ///<returns></returns>

       publicstaticWriteableBitmap
MeanFilterProcess(WriteableBitmap src)////9均值滤波处理

       {

           if(src!=null
)

           {

           int
w = src.PixelWidth;

           int
h = src.PixelHeight;

           WriteableBitmap
filterImage =newWriteableBitmap(w,h);

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

           byte[]
tempMask = (byte[])temp.Clone();

           for
(int j = 1; j < h - 1; j++)

           {

               for
(int i = 4; i < w * 4 - 4; i += 4)

               {

                   temp[i + j * w * 4] = (byte)((tempMask[i
- 4 + (j - 1) * w * 4] + tempMask[i + (j - 1) * w * 4] + tempMask[i + 4 + (j - 1) * w * 4]

                       + tempMask[i - 4 + j * w * 4] + tempMask[i + 4 + j * w * 4] + tempMask[i
- 4 + (j + 1) * w * 4] + tempMask[i + (j + 1) * w * 4]

                       + tempMask[i + 4 + (j + 1) * w * 4]) / 8);

                   temp[i + 1 + j * w * 4] = (byte)((tempMask[i
- 4 + 1 + (j - 1) * w * 4] + tempMask[i + 1 + (j - 1) * w * 4] + tempMask[i + 1 + 4 + (j - 1) * w * 4]

                       + tempMask[i + 1 - 4 + j * w * 4] + tempMask[i + 1 + 4 + j * w *
4] + tempMask[i + 1 - 4 + (j + 1) * w * 4] + tempMask[i + 1 + (j + 1) * w * 4]

                       + tempMask[i + 1 + 4 + (j + 1) * w * 4]) / 8);

                   temp[i + 2 + j * w * 4] = (byte)((tempMask[i
+ 2 - 4 + (j - 1) * w * 4] + tempMask[i + 2 + (j - 1) * w * 4] + tempMask[i + 2 + 4 + (j - 1) * w * 4]

                       + tempMask[i + 2 - 4 + j * w * 4] + tempMask[i + 2 + 4 + j * w *
4] + tempMask[i + 2 - 4 + (j + 1) * w * 4] + tempMask[i + 2 + (j + 1) * w * 4]

                       + tempMask[i + 2 + 4 + (j + 1) * w * 4]) / 8);

               }

           }

           Stream
sTemp = filterImage.PixelBuffer.AsStream();

           sTemp.Seek(0,
SeekOrigin.Begin);

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

           return
filterImage;

           }

           else

           {

               returnnull;

           }  

       }

[图像效果]

Win8Metro(C#)数字图像处理--2.9图像均值滤波的更多相关文章

  1. Win8 Metro(C#)数字图像处理--3.1图像均值计算

    原文:Win8 Metro(C#)数字图像处理--3.1图像均值计算 /// <summary> /// Mean value computing. /// </summary> ...

  2. Win8Metro(C#)数字图像处理--2.3图像反色

    原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明]     反色公式如下: ...

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

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

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

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

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

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

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

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

  7. Win8Metro(C#)数字图像处理--2.29图像除法运算

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

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

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

  9. Win8Metro(C#)数字图像处理--2.19图像水平镜像

    原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像  [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码]      ...

随机推荐

  1. [Angular Directive] Create a Template Storage Service in Angular 2

    You need to define a <template> to be able to use it elsewhere in your app as a TemplateRef. Y ...

  2. 不使用left-join等多表关联查询,只用单表查询和Java程序,简便实现“多表查询”效果

    上次我们提到,不使用left-loin关联查询,可能是为了提高效率或者配置缓存,也可以简化一下sql语句的编写.只写单表查询,sql真得太简单了.问题是,查询多个表的数据还是非常需要的. 因此,存在这 ...

  3. 【codeforces 750A】New Year and Hurry

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

  4. MKNetworkKit的断点续传SIDownloader下载

    comefrom:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece763105392230e54f73d6f8b9042238fce098 ...

  5. jsp与servlet(转)

    一.基本概念 1.1 Servlet Servlet是一种服务器端的Java应用程序,具有独立于平台和协议的特性,可以生成动态的Web页面.它担当客户请求(Web浏览器或其他HTTP客户程序)与服务器 ...

  6. 利用WPF建立自己的3d gis软件(非axhost方式)(九)SDK自带部分面板的调用

    原文:利用WPF建立自己的3d gis软件(非axhost方式)(九)SDK自带部分面板的调用 先下载SDK:https://pan.baidu.com/s/1M9kBS6ouUwLfrt0zV0bP ...

  7. JAVA从本机获取IP地址

    JAVA从本机获取IP地址 论述: 此篇博客是在工作的时候,需要获得当前网络下面正确的ip地址,在网上查阅很多博客,网上一个比较普遍的说法是通过InetAddress.getLocalHost().g ...

  8. Arcgis api for javascript学习笔记(4.5版本) - 本地部署及代理配置

    在开发过程中,由于api的文件比较多,没必要每个项目都将api加入到解决方案中.况且在VS中如果将api加入解决方案,在编写css或js代码时,由于智能提示需要扫描脚本等文件,会导致VS很卡.所以个人 ...

  9. 0-1分布(伯努利分布)、n 重伯努利分布(二项分布)

    1. 0-1 分布(伯努利分布) 0-1分布又名两点分布,或叫伯努利分布. P{X=k}=pk(1−p)1−k 其中 k=0,1. 伯努利分布未必一定是 0-1 分布,也可能是 a-b 分布,只需满足 ...

  10. VAssist 使用技巧(函数声明定位,比VS的还要强大)

    1. 有了VAX可以关掉C++导航栏,快捷键ALT+M,显示当前打开文档的所有符号,而且可以输入进行过滤 2. 查找文件,shift+alt+o (直接定位) 3. 查找符号shift+alt+s 4 ...