matlab mean 滤波,中值和均值滤波---matlab实现(Median and mean filter ---matlab implementation).doc...

本文档介绍了如何使用MATLAB实现中值和均值滤波。提供了两个函数,avg_filter用于均值滤波,mid_filter用于中值滤波。滤波过程涉及到模板大小设置,对输入图像进行滑动窗口操作,并分别计算均值和中值来替换中心位置的像素值。
摘要由CSDN通过智能技术生成

中值和均值滤波---matlab实现(Median and mean filter ---matlab implementation)

中值和均值滤波---matlab实现(Median and mean filter ---matlab implementation)

%x is the image that needs filtering, and N is the template size (that is, n * n)

Function d=avg_filter (x, n)

A (1:n, 1:n) =1;%a, that is, n * n template, the element is 1

[height, width]=size (x);% input image is hightxwidth, and hight>n, width>n

X1=double (x);

X2=x1;

For i=1:hight-n+1

For j=1:width-n+1

C=x1 (i:i+ (n-1), j:j+ (n-1)),.*a;%, take out X1 from J (I), start n row, n column element, and template multiply

S=sum (sum (c));% the sum of the elements in the C matrix

X2 (i+ (n-1), /2, j+ (n-1), /2) =s/ (n*n);% will assign the mean of the elements after the template operation to the central location of the template

End

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值