annotate toolboxes/AudioInpaintingToolbox/Utils/dictionaries/DCT_Dictionary.m @ 220:0d30f9074dd9

Merge
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 15:56:39 +0100
parents 56d719a5fd31
children
rev   line source
ivan@138 1 function D = DCT_Dictionary(param)
ivan@138 2 % Windowed DCT dictionary
ivan@138 3 %
ivan@138 4 % Usage:
ivan@138 5 % D = DCT_Dictionary(param)
ivan@138 6 %
ivan@138 7 %
ivan@138 8 % Inputs [and default values]:
ivan@138 9 % - param.N: frame length [256]
ivan@138 10 % - param.redundancyFactor: redundancy factor to adjust the number of
ivan@138 11 % frequencies [1]. The number of atoms in the dictionary equals
ivan@138 12 % param.N*param.redundancyFactor
ivan@138 13 % - param.wd: weigthing window function [@wSine]
ivan@138 14 %
ivan@138 15 % Output:
ivan@138 16 % - Dictionary: D
ivan@138 17 %
ivan@138 18 %
ivan@138 19 % -------------------
ivan@138 20 %
ivan@138 21 % Audio Inpainting toolbox
ivan@138 22 % Date: June 28, 2011
ivan@138 23 % By Valentin Emiya, Amir Adler, Maria Jafari
ivan@138 24 % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt).
ivan@138 25 % Windowed DCT dictionary
ivan@138 26 %
ivan@138 27
ivan@138 28 % Check and load default parameters
ivan@138 29 defaultParam.N = 256;
ivan@138 30 defaultParam.redundancyFactor = 1;
ivan@138 31 defaultParam.wd = @wSine;
ivan@138 32
ivan@138 33 if nargin<1
ivan@138 34 param = defaultParam;
ivan@138 35 else
ivan@138 36 names = fieldnames(defaultParam);
ivan@138 37 for k=1:length(names)
ivan@138 38 if ~isfield(param,names{k}) || isempty(param.(names{k}))
ivan@138 39 param.(names{k}) = defaultParam.(names{k});
ivan@138 40 end
ivan@138 41 end
ivan@138 42 end
ivan@138 43 K = param.N*param.redundancyFactor; % number of atoms
ivan@138 44 wd = param.wd(param.N); % weigthing window
ivan@138 45 u = 0:(param.N-1); % time
ivan@138 46 k=0:K-1; % frequency
ivan@138 47 D = diag(wd)*cos(pi/K*(u.'+1/2)*(k+1/2));
ivan@138 48
ivan@138 49 % normalisation
ivan@138 50 D = D*diag(1./sqrt(diag(D'*D)));
ivan@138 51 return