Win8 Metro(C#)数字图像处理--2.67图像最大值滤波器
原文:Win8 Metro(C#)数字图像处理--2.67图像最大值滤波器
[函数名称]
最大值滤波器WriteableBitmap MaxFilterProcess(WriteableBitmap src)
[算法说明]
最大值滤波属于非线性滤波方法,它是一种基于排序统计理论的可有效抑制噪声的非线性平滑滤波
器,基本原理是把数字图像或数字序列中一点的值用该点的一个临域中各点值的最大值替换。
[函数代码]
/// <summary>
/// Max value filter.
/// </summary>
/// <param name="src">The source image.</param>
/// <returns></returns>
public static WriteableBitmap MaxFilterProcess(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 = 0;
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 = 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];
}
}
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.67图像最大值滤波器的更多相关文章
- Win8 Metro(C#)数字图像处理--2.68图像最小值滤波器
原文:Win8 Metro(C#)数字图像处理--2.68图像最小值滤波器 /// <summary> /// Min value filter. /// </summary> ...
- Win8 Metro(C#)数字图像处理--3.2图像方差计算
原文:Win8 Metro(C#)数字图像处理--3.2图像方差计算 /// <summary> /// /// </summary>Variance computing. / ...
- Win8 Metro(C#)数字图像处理--3.3图像直方图计算
原文:Win8 Metro(C#)数字图像处理--3.3图像直方图计算 /// <summary> /// Get the array of histrgram. /// </sum ...
- Win8 Metro(C#)数字图像处理--3.4图像信息熵计算
原文:Win8 Metro(C#)数字图像处理--3.4图像信息熵计算 [函数代码] /// <summary> /// Entropy of one image. /// </su ...
- Win8 Metro(C#)数字图像处理--3.5图像形心计算
原文:Win8 Metro(C#)数字图像处理--3.5图像形心计算 /// <summary> /// Get the center of the object in an image. ...
- Win8 Metro(C#)数字图像处理--3.1图像均值计算
原文:Win8 Metro(C#)数字图像处理--3.1图像均值计算 /// <summary> /// Mean value computing. /// </summary> ...
- Win8 Metro(C#)数字图像处理--2.74图像凸包计算
原文:Win8 Metro(C#)数字图像处理--2.74图像凸包计算 /// <summary> /// Convex Hull compute. /// </summary> ...
- Win8 Metro(C#)数字图像处理--2.52图像K均值聚类
原文:Win8 Metro(C#)数字图像处理--2.52图像K均值聚类 [函数名称] 图像KMeans聚类 KMeansCluster(WriteableBitmap src,i ...
- Win8 Metro(C#)数字图像处理--2.45图像雾化效果算法
原文:Win8 Metro(C#)数字图像处理--2.45图像雾化效果算法 [函数名称] 图像雾化 AtomizationProcess(WriteableBitmap src,i ...
随机推荐
- java pns
http://autumnrain-zgq.iteye.com/blog/1743279 http://blog.csdn.net/a351945755/article/details/2218939 ...
- Log4erl
http://developerworks.github.io/2011/05/16/erlang-use-log4erl/ Erlang 使用Log4erl all = debug < inf ...
- SQL SERVER CHARINDEX功能
CHARINDEX功能经常用于通过在字符或字符串中的字符范围搜索. 假定被搜索的字符包括字符搜索,然后该函数返回一个非零整数,的字符在被搜索的字符中的開始位数.即CHARINDEX函数返回字符或者字符 ...
- Zepto.js touch,tap增加 touch模块深入分析
1. touch库实现了什么和引入背景 click事件在移动端上会有 300ms 的延迟,同时因为需要 长按 , 双触击 等富交互,所以我们通常都会引入类似 zepto 这样的库.zepto 中tou ...
- sqoop 1.4.7 安装配置/连接测试
环境: hadoop2.7.7 mysql 8 zk 3.4.10 hive 3 1.上传并解压tar包后进入conf目录 拷贝sqoop-env-template.sh并重命名为sqoop-env. ...
- CentOS 挂载iso文件配置yum源
1.挂载iso 准备好centos的光盘镜像 挂载前的准备; mkdir -p /dev/centos mkdir -p /mnt/local_yum 挂载 mount -o loop /opt/s ...
- Adaptive partitioning scheduler for multiprocessing system
A symmetric multiprocessing system includes multiple processing units and corresponding instances of ...
- 让C#语言充当自身脚本!——.NET中的动态编译
原文:让C#语言充当自身脚本!--.NET中的动态编译 代码的动态编译并执行是.NET平台提供给我们的很强大的一个工具,用以灵活扩展(当然是面对内部开发人员)复杂而无法估算的逻辑,并通过一些额外的代码 ...
- 类的XML序列化(XML Serialization)
最近做的一个ASP.NET项目中,需要在一个页面中维护一个类的数组,在每次页面刷新的使其前一次的状态保持不变.开始错误的使用了static,导致了致命的共享错误.后来突然想起C#类能够使用XML序列化 ...
- Arcgis api for javascript学习笔记(4.5版本) - 本地部署及代理配置
在开发过程中,由于api的文件比较多,没必要每个项目都将api加入到解决方案中.况且在VS中如果将api加入解决方案,在编写css或js代码时,由于智能提示需要扫描脚本等文件,会导致VS很卡.所以个人 ...