Commit a08c0210 authored by Marina Kreme's avatar Marina Kreme
Browse files

refactor

parent c78b421b
Pipeline #5949 passed with stage
in 4 minutes and 51 seconds
function x_interp= solver_tfgm_interp(X, mask, idgt)
%% x_interp= solver_tfgm_interp(X, mask, idgt)
function x_est= interpolation_solver(x, mask, dgt, idgt, dgt_params,...,
signal_params, fig_dir)
%% x_est= interpolation_solver(x, mask, dgt, idgt, dgt_params,...,
% signal_params, fig_dir)
% Time-frequency fading solver using linear interpolation and random phases
% This function apply a linear interpolation along
% the frequency axis of the magnitude of observation time-frequency matrix
% and draws the related phase uniformly at random.
%
% Inputs:
% - X: time-frequency matrix
% - mask: binary mask
% - idgt: Inverse of Gabor transform operator
% - x (nd array): mix signal
% - mask (nd- array): time-frequency mask
% - idgt,dgt (handle): DGT and IDGT . see utils/get_stft_operators.m
% - dgt_params (struct) : DGT parameters
% - signal_params (struct) . :signals parameters
% - fig_dir : folder where figures are stored
% Outputs:
% -x_interp: estimated signal
% -x_est (nd array): estimated signal
%
%
% Author: Marina KREME
%%
X_abs = abs(X);
X_ang = angle(X);
x_tf = dgt(x);
x_abs = abs(x_tf);
x_ang = angle(x_tf);
mask_copy = mask;
%% modulus interpolation
Y = X_abs.*(1-mask_copy);
%%
y_tf = x_abs.*(1-mask_copy);
figure;
plotdgtreal(y_tf,dgt_params.('hop'), dgt_params.('nbins'), signal_params.('fs'));
title('Mask Before Interpolated TF matrix')
saveas(gcf,fullfile(fig_dir,'interp_mask.pdf'));
figure; imagesc(Y); title('before interp');
Z = (Y==0);
%%
z_tf = (y_tf==0);
y_tf(z_tf) = interp1(find(~z_tf),y_tf(~z_tf), find(z_tf),'linear');
Y(Z) = interp1(find(~Z),Y(~Z), find(Z),'linear');
figure; imagesc(Y); title('after interp')
figure
plotdgtreal(y_tf,dgt_params.('hop'), dgt_params.('nbins'), signal_params.('fs'));
title('Interpolated TF matrix')
saveas(gcf,fullfile(fig_dir,'interp_tf_est.pdf'));
%%
X_ang(mask==1) = 2*pi*rand(sum(mask(:)),1);
X_interp = abs(Y).*exp(1i.*X_ang);
x_interp = compute_idgt(X_interp, idgt);
x_ang(mask==1) = 2*pi*rand(sum(mask(:)),1);
x_est = abs(y_tf).*exp(1i.*x_ang);
x_est = idgt(x_est);
figure;
plot_spectrogram(x_est, dgt_params,signal_params, dgt);
title('Reconstructed signal by interp')
saveas(gcf,fullfile(fig_dir,'interp_sig_est.pdf'));
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment