Win8 Metro(C#)数字图像处理--2.69中点滤波器
原文: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>
[图像效果]
Win8 Metro(C#)数字图像处理--2.69中点滤波器的更多相关文章
- Win8 Metro(C#)数字图像处理--2.75灰度图像的形态学算法
原文:Win8 Metro(C#)数字图像处理--2.75灰度图像的形态学算法 前面章节中介绍了二值图像的形态学算法,这里讲一下灰度图的形态学算法,主要是公式,代码略. 1,膨胀算法 2,腐蚀算法 3 ...
- Win8 Metro(C#)数字图像处理--4图像颜色空间描述
原文:Win8 Metro(C#)数字图像处理--4图像颜色空间描述 图像颜色空间是图像颜色集合的数学表示,本小节将针对几种常见颜色空间做个简单介绍. /// <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#)数字图像处理--2.73一种背景图像融合特效
原文:Win8 Metro(C#)数字图像处理--2.73一种背景图像融合特效 /// <summary> /// Image merge process. /// </summar ...
- 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> ...
随机推荐
- 栈溢出笔记1.9 认识SEH
从本节開始,我们就要研究一些略微高级点的话题了,如同在1.2节中看到的,Windows中为抵抗栈溢出做了非常多保护性的检查工作,编译的程序默认开启了这些保护. 假设我们不能绕过这些保护.那么我们的Sh ...
- Linux 网络编程系列教程
一.基础理论篇 01.网络协议入门 02.LAN.WAN.WLAN.VLAN 和 VPN 的区别 03.IP 地址介绍 04.广播地址介绍 05.无连接和面向连接协议的区别 06.因特网的IP协议是不 ...
- php如何实现读取网易有道词典输出单词的xml格式并且转化为html形式
php实现读取网易有道词典输出单词的xml格式并且转化为html形式 一.总结 一句话总结:将xml中的文件用preg_match_all读出来,然后组合成想要的数据 1.explode除了爆炸的意思 ...
- easyui样式及js导入顺序及刷新回车的问题
在使用easyui时,需要导入样式表及其js文件,在导入时.不光要遵守jquery包在easyui包的前面,还需要把样式表放在js的前边 <link type="text/css&qu ...
- Graphics-Processing Architecture Based on Approximate Rendering
BACKGROUND The present invention generally relates to the processing of graphics data, and particula ...
- 小强的HTML5移动开发之路(22)—— Adobe DreamWeaver CS6安装与破解
首先说明一下,这里介绍Adobe DreamWeaver CS6的安装与破解是为了后面的jQuery Mobile框架使用做好准备. 一.首先去Adobe官网下载:http://www.adobe.c ...
- sql server中的TimeStamp时间戳与UniqueIdentifier数据类型
TimeStamp SQL Server timestamp 数据类型与时间和日期无关.SQL Server timestamp 是二进制数字,它表明数据库中数据修改发生的相对顺序.实现 timest ...
- Ubuntu 安装 SSH server 并配置 SSH 无密码登录
https://hinine.com/install-and-configure-ssh-server-on-ubuntu/ Ubuntu 安装 SSH server 并配置 SSH 无密码登录 发表 ...
- python io操作
一次性读取 # 读取文件 # 默认打开文件的方式是只读 file = None try: file = open("f:/test.sql") print(file.name) # ...
- 【77.39%】【codeforces 734A】Anton and Danik
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...