当前位置:首页 » 操作系统 » 平滑滤波算法

平滑滤波算法

发布时间: 2023-08-26 12:15:10

⑴ 一组数据x[i],对其进行滑动平均滤波,得到在matlab中实现的程序,要求运行完能出对比图的。

clear
clc
x=randn(1,100);
%x为要滤波的信号
m=5;%表示平滑滤波窗长度,这是长度为奇数的情况
%前m/2,最后m/2个点没滤波,设为原来的值就行
for i=1:length(x)-m+1
y(i+(m-1)/2)=sum(x(i:i+m-1))/m;
end
figure(1);
plot(x,'r');hold on;plot(y,'g');hold off;
这是最简单的,不知道你需要基于什么算法的平滑滤波!有重心法的,算术滑动平均的,变参数双指数平滑方法,还有用插值的方式去平滑的

⑵ 数字信号测量中的平滑算法怎么算

其实最简单的平滑算法就是对之前的数据求一个平均值,即
y(t) = (y(t-n)+y(t-n+1)+...+y(t))/(n+1)
其实,这么做的理由很简单,这相当于是一个n+1阶的FIR滤波器,然后每个系数都是1/(n+1)。
说白了,就是一个低通滤波器,因此可以起到抑制毛刺等高频信号的结果。
其实,我个人认为,如果你好好设计一个FIR滤波器,然后按照那个系数来进行调整,比这种方法去掉毛刺的效果好得多,你可以利用matlab的工具fdatool,有不懂可以继续追问。

⑶ 高斯滤波的算法原理

高斯滤波实质上是一种信号的滤波器,其用途是信号的平滑处理,人们知道数字图像用于后期应用,其噪声是最大的问题,由于误差会累计传递等原因,很多图像处理教材会在很早的时候介绍Gauss滤波器,用于得到信噪比SNR较高的图像(反应真实信号)。与此相关的有Gauss-Laplace变换,其实就是为了得到较好的图像边缘,先对图像做Gauss平滑滤波,剔除噪声,然后求二阶导矢,用二阶导的过零点确定边缘,在计算时也是频域乘积=>空域卷积。
滤波器就是建立的一个数学模型,通过这个模型来将图像数据进行能量转化,能量低的就排除掉,噪声就是属于低能量部分。
若使用理想滤波器,会在图像中产生振铃现象。采用高斯滤波器的话,系统函数是平滑的,避免了振铃现象。

⑷ 用MATLAB实现频域平滑滤波以及图像去噪代码

%%%%%%%%spatial frequency (SF) filtering by low pass filter%%%%%%%%

% the SF filter is unselective to orientation (doughnut-shaped in the SF
% domain).

[FileName,PathName,FilterIndex] = uigetfile ;
filename = fullfile(PathName, FileName) ;

[X map] = imread(filename, fmt); % read image
L = double(X); % transform to double
%%%%%%%%%%%%% need to add (-1)x+y to L

% calculate the number of points for FFT (power of 2)
fftsize = 2 .^ ceil(log2(size(L)));
% 2d fft
Y = fft2(X, fftsize(1), fftsize (2));
Y = fftshift(Y);

% obtain frequency (cycles/pixel)
f0 = floor([m n] / 2) + 1;
fy = ((m: -1: 1) - f0(1) + 1) / m;
fx = ((1: n) - f0(2)) / n;
[mfx mfy] = meshgrid(fx, fy);

% calculate radius
SF = sqrt(mfx .^ 2 + mfy .^ 2);

% SF-bandpass and orientation-unselective filter
filt = SF > k0;

A_filtered = filt .* A; % SF filtering
L_filtered = real(ifft2(ifftshift(A_filtered))); % IFFT
L_filtered = L_filtered(1: size(L, 1), 1: size(L, 2));
%%%%%%%%%%need to add (-1)x + y to L_filtered

% show
figure(1);
clf reset;
colormap gray;

% plot image
subplot(2, 2, 1);
imagesc(L);
colorbar;
axis square;
set(gca, 'TickDir', 'out');
title('original image');
xlabel('x');
ylabel('y');
imwrite(L, fullfile(FilePath, 'original image.bmp'), 'bmp') ;

% plot amplitude
A = abs(A);
A = log10(A);
% spectral amplitude
subplot(2, 2, 2);
imagesc(fx, fy, A);
axis xy;
axis square;
set(gca, 'TickDir', 'out');
title('amplitude spectrum');
xlabel('fx (cyc/pix)');
ylabel('fy (cyc/pix)');
imwrite(A, fullfile(FilePath, 'amplitude spectrum.bmp'), 'bmp') ;

% filter in the SF domain
subplot(2, 2, 3);
imagesc(fx, fy, filt);
axis xy;
axis square;
set(gca, 'TickDir', 'out');
title('filter in the SF domain');
xlabel('fx (cyc/pix)');
ylabel('fy (cyc/pix)');
imwrite(filt, fullfile(FilePath, 'filter in SF.bmp'), 'bmp') ;

% filtered image
subplot(2, 2, 4);
imagesc(L_filtered);
colorbar;
axis square;
set(gca, 'TickDir', 'out');
title('filtered image');
xlabel('x');
ylabel('y');
imwrite(filtered, fullfile(FilePath, 'filtered image.bmp'), 'bmp');

%%%%%%%%%%%%%%%%%median filter%%%%%%%%%%%%%%%%
[FileName,PathName,FilterIndex] = uigetfile ;
filename = fullfile(PathName, FileName) ;

[LNoise map] = imread(filename, fmt); % read image
L = medfilt2(LNoise, [3 3]); % remove the noise with 3*3 block

figure ;
imshow(LNoise) ;
title('image before fitlering') ;
figure
imshow(L)
title('filtered image') ;
imwrite(FilePath, 'filtered image.bmp', bmp)

⑸ 说明算术平均滤波,加权平均滤波和滑动平均滤波之间的区别以及各自的用途

算术平均滤波每次采样值所占的比例均相等,可用于任何场合:如压力、流量等。加权平均滤波则每次采样值所占的比例不等,可以突出某些部分,使其所占的比例增大,但各次采样的系数总和为∑Ci=1;这种滤波主要用于那些想突出采样的某些部分的场合。而滑动平均滤波则是每次只更新一个采样值,因而采样速度快。此滤波主要用于实时性要求比较快的场合。

热点内容
攻城掠地怎么开服务器 发布:2025-03-05 00:11:31 浏览:482
怎么看汉兰达什么配置 发布:2025-03-05 00:08:29 浏览:282
服务器装系统如何加载硬盘驱动 发布:2025-03-04 23:59:50 浏览:151
vf编程语言 发布:2025-03-04 23:54:17 浏览:179
新建文件夹磁力链接 发布:2025-03-04 23:49:56 浏览:467
如何改成qq旧密码 发布:2025-03-04 23:49:08 浏览:707
服务器ip波动 发布:2025-03-04 23:39:12 浏览:878
ppt设计c语言 发布:2025-03-04 23:32:41 浏览:773
我的世界电脑版怎么玩神奇宝贝服务器 发布:2025-03-04 23:32:37 浏览:120
sqlwithas排序 发布:2025-03-04 23:30:21 浏览:837