[39b069]: gabor / tfmat.m  Maximize  Restore  History

Download this file

203 lines (179 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
function F=tfmat(ttype,p2,p3,p4,p5)
%TFMAT Matrix of transform / operator
% Usage: F=tfmat('fourier',L);
% F=tfmat('dcti',L);
% F=tfmat('dgt',g,a,M);
% F=tfmat('dwilt',g,M);
% F=tfmat('wmdct',g,M);
% F=tfmat('zak',L,a);
% F=tfmat('gabmul',sym,a);
% F=tfmat('spread',c);
%
% `tfmat` returns a matrix *F* containing the basis functions / atoms of
% one of the transforms in the toolbox. The atoms are placed as column
% vectors in the matrix. A forward transform (analysis) can be done by::
%
% c=F'*f;
%
% and a backwards or adjoint transform (synthesis) can be done by::
%
% r=F*c;
%
% The possibilities are:
%
% `tfmat('fourier',L)` returns the matrix of the unitary Fourier
% transform of length *L*. See |dft|_.
%
% `tfmat('dcti',L)` returns the matrix of the DCTI transform of length
% *L*. Similarly for `'dctii'`, `'dctiii'`, `'dctiv'`, `'dsti'`, `'dstii'`,
% `'dstiii'` or `'dstiv'`.
%
% `tfmat('dgt',g,a,M)` returns a matrix containing all the atoms of the
% Gabor frame with window g and lattice constants *a* and *M*.
% `tfmat('dgt',g,a,M,L)` will do the same for a FIR window *g*.
%
% `tfmat('dwilt',g,M)` returns a matrix containing all the atoms of the
% Wilson basis with window *g* and *M* channels. `tfmat(g,M,L)` will do the
% same for a FIR window *g*.
%
% `tfmat('wmdct',g,M)` and `tfmat('wmdct',g,M,L)` does the same for an WMDCT
% with *M* channels.
%
% `tfmat('gabmul',sym,a)` return the matrix of the Gabor multiplier with
% symbol sym and time shift *a*. `tfmat('gabmul',c,g,a)` does the same using
% the window *g* for both analysis and
% synthesis. `tfmat('gabmul',sym,ga,gs,a)` does the same using *ga* as
% analysis window and *gs* as synthesis window.
%
% `tfmat('spread',c)` returns the matrix of the spreading operator with
% symbol *c*.
%
% `tfmat('zak',L,a)` returns the transform matrix for a Zak transform of
% length *L* and parameter *a*.
%
% This function should mainly be used for educational purposes or for
% experimenting with systems, as the generated matrix can
% become very large.
%
% See also: dft, dcti, dsti, dgt, dwilt, wmdct, gabmul, spreadop
if (nargin<1) || ~ischar(ttype)
error('You must specify the transform type')
end;
switch(lower(ttype))
case {'fourier','dft'}
error(nargchk(2,2,nargin));
F=idft(eye(p2));
case {'dcti'}
error(nargchk(2,2,nargin));
F=dcti(eye(p2))';
case {'dctii'}
error(nargchk(2,2,nargin));
F=dctii(eye(p2))';
case {'dctiii'}
error(nargchk(2,2,nargin));
F=dctiii(eye(p2))';
case {'dctiv'}
error(nargchk(2,2,nargin));
F=dctiv(eye(p2))';
case {'dsti'}
error(nargchk(2,2,nargin));
F=dsti(eye(p2))';
case {'dstii'}
error(nargchk(2,2,nargin));
F=dstii(eye(p2))';
case {'dstiii'}
error(nargchk(2,2,nargin));
F=dstiii(eye(p2))';
case {'dstiv'}
error(nargchk(2,2,nargin));
F=dstiv(eye(p2))';
case {'gabor','dgt'}
error(nargchk(4,5,nargin));
g=p2;
if nargin==4
L=length(g);
else
L=p5;
end;
a=p3;
M=p4;
N=L/a;
c=reshape(eye(M*N),M,N,M*N);
F=idgt(c,g,a);
case {'wilson','dwilt'}
error(nargchk(3,4,nargin));
g=p2;
if nargin==3
L=length(g);
else
L=p4;
end;
M=p3;
N=L/M;
c=reshape(eye(M*N),2*M,N/2,M*N);
F=idwilt(c,g);
case {'wmdct'}
error(nargchk(3,4,nargin));
g=p2;
if nargin==3
L=length(g);
else
L=p4;
end;
M=p3;
N=L/M;
c=reshape(eye(M*N),M,N,M*N);
F=iwmdct(c,g);
case {'spread','spreadop'}
error(nargchk(2,2,nargin));
c=p2;
L=size(c,2);
F=spreadop(eye(L),c);
case {'gabmul'}
error(nargchk(3,5,nargin));
sym=p2;
M=size(sym,1);
N=size(sym,2);
switch(nargin)
case 3
a=p3;
L=a*N;
F=gabmul(eye(L),sym,a);
case 4
g=p3;
a=p4;
L=a*N;
F=gabmul(eye(L),sym,g,a);
case 5
ga=p3;
gs=p4;
a=p5;
L=a*N;
F=gabmul(eye(L),sym,ga,gs,a);
end;
case {'ndgt'}
error(nargchk(5,5,nargin));
g=p2;
a=p3;
M=p4;
L=p5;
%!!! the computation using eye matrix doesn't work if M>sigLen
N=length(a); % number of time positions
MN=sum(M); % total number of frame elements
F=zeros(L,MN);
jj=0;
for ii=1:N
c={eye(M(ii))};
F(:,jj+(1:M(ii)))=indgt(c,g(ii),a(ii),L);
jj=jj+M(ii);
end
case {'zak'}
error(nargchk(3,5,nargin))
L=p2;
a=p3;
N=L/a;
c=reshape(eye(L),a,N,L);
F=izak(c);
otherwise
error('Unknown transform.');
end;

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks