git-svn-id: http://moon:8086/svn/matlab/trunk@40 801c6759-fa7c-4059-a304-17956f83a07c
15 lines
442 B
Matlab
15 lines
442 B
Matlab
function [xs, g, PSDx, PSDy] = wiener_fd(x, y, sigma_noise)
|
|
N = length(x);
|
|
Y = fft(y);
|
|
X = fft(x);
|
|
PSDx = 1/N*abs(X).^2; % spectral power
|
|
PSDy = 1/N*abs(Y).^2; % spectral power
|
|
|
|
k = sqrt(sum(PSDx)./sum(PSDy))
|
|
% fourier transform of the wiener filter
|
|
G = PSDx./(PSDx + sigma_noise.^2);
|
|
% perform the filtering over the fourier
|
|
G = 1/k*G.*PSDx./PSDy;
|
|
xs = ifft(G.*Y);
|
|
g = ifft(G);
|