Win8Metro(C#)数字图像处理--2.9图像均值滤波
原文: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图像均值滤波的更多相关文章
- Win8 Metro(C#)数字图像处理--3.1图像均值计算
原文:Win8 Metro(C#)数字图像处理--3.1图像均值计算 /// <summary> /// Mean value computing. /// </summary> ...
- Win8Metro(C#)数字图像处理--2.3图像反色
原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下: ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.32图像曝光算法
原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法 [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...
- Win8Metro(C#)数字图像处理--2.27图像加法运算
原文:Win8Metro(C#)数字图像处理--2.27图像加法运算 [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...
- Win8Metro(C#)数字图像处理--2.28图像乘法运算
原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算 [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...
- Win8Metro(C#)数字图像处理--2.29图像除法运算
原文:Win8Metro(C#)数字图像处理--2.29图像除法运算 [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...
- Win8Metro(C#)数字图像处理--2.26图像减法
原文:Win8Metro(C#)数字图像处理--2.26图像减法 [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...
- Win8Metro(C#)数字图像处理--2.19图像水平镜像
原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像 [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码] ...
随机推荐
- 【Windows Defender Antivirus Service 永久禁用 】
cmd 管理员运行 执行 reg add “HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender” /v “DisableAn ...
- 利用huson的日志获取编译错误信息的做法
作者:朱金灿 来源:http://blog.csdn.net/clever101 使用hudson编译一百多个VC工程,输出的日志有6M之大,摆在我面前的一个问题是如何利用这个日志信息来获取编译错误信 ...
- [React Router v4] Render Nested Routes
With React Router v4 the entire library is built as a series of React components. That means that cr ...
- 前端调用百度API
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- OOA/OOD/OOP 转载
OOA/OOD/OOP OOA Object-Oriented Analysis:面向对象分析方法 是在一个系统的开发过程中进行了系统业务调查以后,按照面向对象的思想来分析问题.OOA与结构化分析有较 ...
- Thermal zone monitoring in an electronic device
FIELD One embodiment of the invention relates to a closed loop thermal control process in a portable ...
- leveldb学习:skiplist
leveldb中的memtable仅仅是一个封装类,它的底层实现是一个跳表. 跳表是一种基于随机数的平衡数据结构.其它的平衡数据结构还有红黑树.AVL树.但跳表的原理比它们简单非常多.跳表有点像链表, ...
- BZOJ 1084 [SCOI2005]最大子矩阵 - 动态规划
传送门 题目大意: 从矩阵中取出k个互不重叠的子矩阵,求最大的和. 题目分析: 对于m=1,直接最大m子段和. 对于m=2: \(dp[i][j][k]\)表示扫描到第一列i和第2列j时选取了k个矩阵 ...
- Eclipse Che开发Spring Web应用(入门) (二)
在上篇博客中我们介绍了如何安装Eclipse Che这种浏览器SDK之后,收到了许多开发者的提问,为了方便初学者开发Java web应用,笔者又一步步实践了spring web开发(demo)过程,欢 ...
- boost::any在降低模块之间耦合性的应用
作者:朱金灿 来源:http://blog.csdn.net/clever101 在开发大型系统中,遵循这样一个原则:模块之间低耦合,模块内高内聚.比如系统中模块有界面模块和算法模块两种,一般是界面模 ...