原文:Win8 Metro(C#)数字图像处理--2.68图像最小值滤波器

        /// <summary>
/// Min value filter.
/// </summary>
/// <param name="src">The source image.</param>
/// <returns></returns>
public static WriteableBitmap MinFilterProcess(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;
int tempr = 0, tempb = 0, tempg = 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;
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];
}
}
temp[i * 4 + j * w * 4] = (byte)tempb;
temp[i * 4 + 1 + j * w * 4] = (byte)tempg;
temp[i * 4 + 2 + j * w * 4] = (byte)tempr;
}
}
Stream sTemp = filterImage.PixelBuffer.AsStream();
sTemp.Seek(0, SeekOrigin.Begin);
sTemp.Write(temp, 0, w * 4 * h);
return filterImage;
}
else
{
return null;
}
}

[图像效果]



Win8 Metro(C#)数字图像处理--2.68图像最小值滤波器的更多相关文章

  1. Win8 Metro(C#)数字图像处理--2.67图像最大值滤波器

    原文:Win8 Metro(C#)数字图像处理--2.67图像最大值滤波器  [函数名称]   最大值滤波器WriteableBitmap MaxFilterProcess(WriteableBi ...

  2. Win8 Metro(C#)数字图像处理--3.2图像方差计算

    原文:Win8 Metro(C#)数字图像处理--3.2图像方差计算 /// <summary> /// /// </summary>Variance computing. / ...

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

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

  4. Win8 Metro(C#)数字图像处理--3.4图像信息熵计算

    原文:Win8 Metro(C#)数字图像处理--3.4图像信息熵计算 [函数代码] /// <summary> /// Entropy of one image. /// </su ...

  5. Win8 Metro(C#)数字图像处理--3.5图像形心计算

    原文:Win8 Metro(C#)数字图像处理--3.5图像形心计算 /// <summary> /// Get the center of the object in an image. ...

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

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

  7. Win8 Metro(C#)数字图像处理--2.74图像凸包计算

    原文:Win8 Metro(C#)数字图像处理--2.74图像凸包计算 /// <summary> /// Convex Hull compute. /// </summary> ...

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

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

  9. Win8 Metro(C#)数字图像处理--2.45图像雾化效果算法

    原文:Win8 Metro(C#)数字图像处理--2.45图像雾化效果算法 [函数名称]   图像雾化         AtomizationProcess(WriteableBitmap src,i ...

随机推荐

  1. 小强的HTML5移动开发之路(43)——JqueryMobile页眉、工具栏和标签栏导航

    一.页眉 1.添加页眉和页脚 <div data-role="header"> <h1>第 1 页</h1> </div> < ...

  2. [HTML5] Focus management using CSS, HTML, and JavaScript

    Something important to consider when coding a web application is managing the user's focus. For keyb ...

  3. Erlang 聊天室程序

    Erlang 聊天室程序( 一) Erlang 聊天室程序(二) 客户端的退出 Erlang 聊天室程序(三) 数据交换格式---json的decode Erlang 聊天室程序(四) 数据交换格式- ...

  4. 轻松学习JavaScript十八:DOM编程学习之DOM简单介绍

    一DOM概述 DOM(文档对象模型)是HTML和XML的应用程序接口(API).DOM将把整个页面规划成由节点层级构成的文档. DOM描绘了一个层次化的节点树,执行开发者加入,移除和改动页面的某一部分 ...

  5. scala 主从构造器

    package cn.scala_base.oop.scalaclass /** * 构造器分为两种,一种是主构造器,另一种是从构造器,所有的从构造器必须在其方法体 * 的第一行调用主构造器 * * ...

  6. maven Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

    如果你可以确认你的maven Dependencies中已经导入了如下的jar包,那么你就要检查下Deployment Assembly 选中项目 alt+enter,然后查看maven依赖有没有被添 ...

  7. js 如何一次性删除数组中的多个元素

    用for循环或者forEach遍历数组的话,在方法体内部splice都得不到正确的结果.有什么好的办法解决这个问题吗? var arr=[2,3,5,7]; arr.forEach(function( ...

  8. [Android]使用化名(alias)功能防止相同资源的重复

    在为一个应用匹配不同资源文件的时候,有时可能需要在不同适配类型的资源路径下使用相同的资源文件,这时使用alias方法可以防止相同资源文件的重复,提高效率.以下摘自Android开发文档http://d ...

  9. 将memo转化为JPG输出,使用Memo1.PaintTo(Bitmap.Canvas)

    unit unit1; interface uses  Windows, Messages, SysUtils, Graphics, Controls, Forms, StdCtrls,  Class ...

  10. Failed during checkstyle execution: Unable to find suppressions file at location: src/checkstyle/checkstyle-suppressions.xml

    <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot ...