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) [函数代码] ...
随机推荐
- 为什么 ["1", "2", "3"].map(parseInt) 返回 [1,NaN,NaN]?
在 javascript 中 ["1","2","3"].map(parseInt) ,2,3] 却是 [1,NaN,NaN]? 我们首先回 ...
- erlang数字转字符串
http://fengmm521.blog.163.com/blog/static/2509135820147922355273/ 如果有一个数字,你想要转换成字符串这个在Erlang中是怎么操作的, ...
- 从张量积(tensor product)到多重线性代数(multilinear algebra)
记张量积的数学记号为 ⊗. 1. linear 假设 V,W 为线性空间(vector spaces),f:V→W是线性(linear)的,如果满足: f(v1+v2)=f(v1)+f(v2)f(αv ...
- Qt写入unicode编码格式的文本(用QChar写入BOM标记,并且列出所有Qt支持的字符集)
1.文本流设置unicode小端模式 2.写入文本前两个字节FF FE 3.字符串转成unicode编码 QList<QByteArray> list = QTextCodec::avai ...
- 前端自动化之路之gulp,node.js
随着现在前端技术的不断发展,和各个公司对前端项目开发更新速度的要求,前端自动化越来越受到大家的重视,之前传统的前端开发方式已经越来越不能满足开发的需求了,于是各种自动化工具随之产生了.而gulp就是其 ...
- Configure Two DataSources ---
67. Data Access 67.1 Configure a DataSource To override the default settings just define a @Bean of ...
- caffe 源码阅读
bvlc:Berkeley Vision and Learning Center. 1. 目录结构 models(四个文件夹均有四个文件构成,deploy.prototxt, readme.md, s ...
- andriod 实现新浪、QQ场地、朋友微信圈、微信朋友分享功能
前言:在自己的学习过程中的一些操作,分享一些理解. 下面将说明什么: 下载链接:http://download.csdn.net/detail/u014608640/7490357 首先.我们须要去S ...
- go 工具链目前[不支持编译 windows 下的动态链接库][1],不过[支持静态链接库][2]
go 工具链目前[不支持编译 windows 下的动态链接库][1],不过[支持静态链接库][2].想要产生dll,可以这样 workaround ,参考 golang [issuse#11058][ ...
- 从 XML 到 XPath
XPath是 W3C(World Wide Website Consortium) 的一个标准.它最主要的目的是为了在 XML1.0 或 XML1.1 文档节点树中定位节点所设计. XPath 即为 ...