MATLAB 中中位值平均滤波法(又称防脉冲干扰平均滤波法)怎么编写程序啊
1个回答
展开全部
写一个小函数,LZ调用它就可以了:
function fi = calc_avg(input,len)
% OUT = CALC_AVG(INPUT,LEN)
% calculate the average by each length LEN of the INPUT;
% INPUT is the input series or matrix need to be filtered;
% LEN is the average filter length, and LEN must be smaller than the input size;
% return OUT is the same size series or matrix of input.
[m,n] = size(input);
input = reshape(input,m*n,1);
if len>=m*n
error('the filter length is too large!');
return
else
input = [input;input(1:len-1)];
out = [];
for i=1:m*n
out(i) = mean(input(i:i+len-1));
end
fi = reshape(out,m,n);
end
function fi = calc_avg(input,len)
% OUT = CALC_AVG(INPUT,LEN)
% calculate the average by each length LEN of the INPUT;
% INPUT is the input series or matrix need to be filtered;
% LEN is the average filter length, and LEN must be smaller than the input size;
% return OUT is the same size series or matrix of input.
[m,n] = size(input);
input = reshape(input,m*n,1);
if len>=m*n
error('the filter length is too large!');
return
else
input = [input;input(1:len-1)];
out = [];
for i=1:m*n
out(i) = mean(input(i:i+len-1));
end
fi = reshape(out,m,n);
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询