comparison toolboxes/AudioInpaintingToolbox/Utils/dictionaries/Gabor_Dictionary.m @ 138:56d719a5fd31 ivand_dev

Audio Inpaintin Toolbox
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Thu, 21 Jul 2011 14:27:47 +0100
parents
children
comparison
equal deleted inserted replaced
137:9207d56c5547 138:56d719a5fd31
1 function D = Gabor_Dictionary(param)
2 % Windowed Gabor dictionary. In this implementation, the dictionary matrix
3 % is the concatenation of a DCT (left part of the matrix) and of a DST
4 % (right part).
5 % Note that one can use this dictionary
6 % - either by constraining the simulaneous selection of cosine and sine
7 % atoms with same frequency in order to implement Gabor atoms;
8 % - or, without any selection constraint, by considering that the
9 % dictionary is not a Gabor dictionary but the concatenation of a DCT and
10 % of a DST.
11 %
12 % Usage:
13 % D = Gabor_Dictionary(param)
14 %
15 % Inputs [and default values]:
16 % - param.N: frame length [256]
17 % - param.redundancyFactor: redundancy factor to adjust the number of
18 % frequencies [1]. The number of atoms in the dictionary equals
19 % param.N*param.redundancyFactor
20 % - param.wd: weigthing window function [@wSine]
21 %
22 % Output:
23 % - Dictionary: D (cosine atoms followed by sine atoms)
24 %
25 %
26 % -------------------
27 %
28 % Audio Inpainting toolbox
29 % Date: June 28, 2011
30 % By Valentin Emiya, Amir Adler, Maria Jafari
31 % This code is distributed under the terms of the GNU Public License version 3 (http://www.gnu.org/licenses/gpl.txt).
32
33 % Check and load default parameters
34 defaultParam.N = 256;
35 defaultParam.redundancyFactor = 1;
36 defaultParam.wd = @wSine;
37
38 if nargin<1
39 param = defaultParam;
40 else
41 names = fieldnames(defaultParam);
42 for k=1:length(names)
43 if ~isfield(param,names{k}) || isempty(param.(names{k}))
44 param.(names{k}) = defaultParam.(names{k});
45 end
46 end
47 end
48 K = param.N*param.redundancyFactor; % number of atoms
49 wd = param.wd(param.N); % weigthing window
50 u = 0:(param.N-1); % time
51 k=0:K/2-1; % frequency
52 D = diag(wd)*[cos(2*pi/K*(u.'+1/2)*(k+1/2)),sin(2*pi/K*(u.'+1/2)*(k+1/2))];
53
54 % normalisation
55 D = D*diag(1./sqrt(diag(D'*D)));
56
57 return