當前位置:首頁 » 操作系統 » 平滑濾波演算法

平滑濾波演算法

發布時間: 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-02-01 14:03:04 瀏覽:256
qq易語言盜號源碼 發布:2025-02-01 14:01:25 瀏覽:810
源神比較好的雲伺服器 發布:2025-02-01 13:55:27 瀏覽:206
黑蘋果idea編譯慢 發布:2025-02-01 13:45:30 瀏覽:548
c和linux 發布:2025-02-01 13:39:38 瀏覽:175
android實現列表 發布:2025-02-01 13:38:06 瀏覽:102
安卓手機為什麼會出現橫條 發布:2025-02-01 13:33:38 瀏覽:625
jqueryajax提交文件上傳 發布:2025-02-01 13:32:03 瀏覽:689
沒連上wifi如何修改wifi密碼 發布:2025-02-01 13:20:42 瀏覽:758
絕對賽車3安卓在哪裡下載 發布:2025-02-01 12:42:30 瀏覽:718