原文:Win8 Metro(C#)数字图像处理--2.69中点滤波器

[函数代码]

<strong>        /// <summary>/// Mid-point filter./// </summary>/// <param name="src">The source image.</param>/// <returns></returns>public static WriteableBitmap MidPointFilterProcess(WriteableBitmap src)中点滤波器{if (src != null){int w = src.PixelWidth;int h = src.PixelHeight;WriteableBitmap filterImage = new WriteableBitmap(w, h);byte[] temp = src.PixelBuffer.ToArray();byte[] tempMask = (byte[])temp.Clone();double[] Gray = new double[9];double gray = 255, graymax = 0;int tempr = 0, tempb = 0, tempg = 0, temprMax = 0, tempgMax = 0, tempbMax = 0;for (int j = 1; j < h - 1; j++){for (int i = 1; i < w - 1; i++){tempb = 0;tempg = 0;tempr = 0;gray = 255;graymax = 0;int[] B = new int[9] { tempMask[i * 4 + j * w * 4], tempMask[(i - 1) * 4 + (j - 1) * w * 4], tempMask[i * 4 + (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 * 4 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + (j + 1) * w * 4] };int[] G = new int[9] { tempMask[i * 4 + 1 + j * w * 4], tempMask[(i - 1) * 4 + 1 + (j - 1) * w * 4], tempMask[i * 4 + 1 + (j - 1) * w * 4], tempMask[(i + 1) * 4 + 1 + (j - 1) * w * 4], tempMask[(i - 1) * 4 + 1 + j * w * 4], tempMask[(i + 1) * 4 + 1 + j * w * 4], tempMask[(i - 1) * 4 + 1 + (j + 1) * w * 4], tempMask[i * 4 + 1 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + 1 + (j + 1) * w * 4] };int[] R = new int[9] { tempMask[i * 4 + 2 + j * w * 4], tempMask[(i - 1) * 4 + 2 + (j - 1) * w * 4], tempMask[i * 4 + 2 + (j - 1) * w * 4], tempMask[(i + 1) * 4 + 2 + (j - 1) * w * 4], tempMask[(i - 1) * 4 + 2 + j * w * 4], tempMask[(i + 1) * 4 + 2 + j * w * 4], tempMask[(i - 1) * 4 + 2 + (j + 1) * w * 4], tempMask[i * 4 + 2 + (j + 1) * w * 4], tempMask[(i + 1) * 4 + 2 + (j + 1) * w * 4] };for (int n = 0; n < 9; n++){Gray[n] = (double)B[n] * 0.114 + (double)G[n] * 0.587 + (double)R[n] * 0.299;if (gray > Gray[n]){gray = Gray[n];tempb = B[n];tempr = R[n];tempg = G[n];}if (graymax < Gray[n]){graymax = Gray[n];tempbMax = B[n];tempgMax = G[n];temprMax = R[n];}}temp[i * 4 + j * w * 4] = (byte)((tempb + tempbMax) / 2);temp[i * 4 + 1 + j * w * 4] = (byte)((tempg + tempgMax) / 2);temp[i * 4 + 2 + j * w * 4] = (byte)((tempr + temprMax) / 2);}}Stream sTemp = filterImage.PixelBuffer.AsStream();sTemp.Seek(0, SeekOrigin.Begin);sTemp.Write(temp, 0, w * 4 * h);return filterImage;}else{return null;}}</strong>

[图像效果]

最后,分享一个专业的图像处理网站(微像素),里面有很多源代码下载:
http://www.zealpixel.com/portal.php


Win8 Metro(C#)数字图像处理--2.69中点滤波器相关推荐

  1. Win8 Metro(C#)数字图像处理--2.52图像K均值聚类

    原文:Win8 Metro(C#)数字图像处理--2.52图像K均值聚类  [函数名称] 图像KMeans聚类      KMeansCluster(WriteableBitmap src,int ...

  2. Win8 Metro(C#)数字图像处理--2.60部分彩色保留算法

    原文:Win8 Metro(C#)数字图像处理--2.60部分彩色保留算法  [函数名称] 部分彩色保留函数       WriteableBitmap PartialcolorProcess(W ...

  3. Win8 Metro(C#)数字图像处理--2.66FloodFill算法

    原文:Win8 Metro(C#)数字图像处理--2.66FloodFill算法  [函数名称] 洪水填充算法函数 WriteableBitmap FloodfillProcess(Writeab ...

  4. Win8 Metro(C#)数字图像处理--3.3图像直方图计算

    原文:Win8 Metro(C#)数字图像处理--3.3图像直方图计算 /// <summary>/// Get the array of histrgram./// </summa ...

  5. Win8 Metro(C#)数字图像处理--2.35图像肤色检测算法

    原文:Win8 Metro(C#)数字图像处理--2.35图像肤色检测算法  [函数名称] 肤色检测函数SkinDetectProcess(WriteableBitmap src) [算法说明] ...

  6. Win8 Metro(C#)数字图像处理--2.50图像运动模糊

    原文:Win8 Metro(C#)数字图像处理--2.50图像运动模糊  [函数名称] 图像运动模糊算法    MotionblurProcess(WriteableBitmap src,int  ...

  7. Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法

    Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法 原文:Win8 Metro(C#)数字图像处理--2.40二值图像轮廓提取算法  [函数名称] 二值图像轮廓提取      ...

  8. Win8 Metro(C#)数字图像处理--2.39二值图像投影

    原文:Win8 Metro(C#)数字图像处理--2.39二值图像投影  [函数名称] 二值图像投影         ImageProjection(WriteableBitmap src) [算 ...

  9. Win8 Metro(C#)数字图像处理--4图像颜色空间描述

    原文:Win8 Metro(C#)数字图像处理--4图像颜色空间描述  图像颜色空间是图像颜色集合的数学表示,本小节将针对几种常见颜色空间做个简单介绍. /// <summary>// ...

最新文章

  1. php技术会议总结,【技术产品】总结PHP编程20大效率要点
  2. map集合遍历_集合框架的部分内容
  3. ScheduledThreadPoolExecutor()定时执行线程池详解,java线程池
  4. Java第三大的数,Java通过排序找出数组第三大数字
  5. 代码管理 ,git 命令整理
  6. c语言pop逆置单链表,C语言实现单链表
  7. asp.net core 中间件详解及项目实战
  8. LeetCode:202. 快乐数
  9. mac上TK Framework double implementation
  10. 智慧小区智能安防设计方案
  11. ssq冷热号:子图之间间隔调整
  12. 公务员面试综合分析真题解析
  13. 数据库连接_由浅入深搭建Mybatis框架
  14. 如何实现复制文本到剪贴板?
  15. R语言27-Prosper 贷款数据分析3
  16. Occupancy Map(Occupancy Grid)的更新
  17. 用什么办法可以解决失眠?
  18. 微信小程序---实现tab选项卡
  19. 七个初学者必下载的Python编程器
  20. 10月深圳礼品展即将启航 带你沉浸式逛展

热门文章

  1. 4*4按键扫描程序c语言,【资料】单片机4*4矩阵键盘扫描程序(c语言+汇编语言2个版本)...
  2. linux qt5.9交叉编译,ubuntu16交叉编译Qt5.9
  3. 矿用巷道巡检机器人_一种井下自动巡检机器人系统
  4. 06-3. 单词长度(15)
  5. 前端图片上坐标连线_平面上三角形“四心”的解析建模
  6. mysql5.7 高可用_基于MySQL 5.7多源复制及Keepalived搭建三节点高可用架构
  7. java 容器的嵌套_java界面设计里怎么实现容器嵌套
  8. pyBoard定时器中断中不能够做什么操作? MicroPython,pyBoard
  9. 一位老司机谈谈掏心窝子的话
  10. arr数组怎么取值_JS 面试之数组的几个不 low 操作