Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[931198]: filterbank / filterbanktight.m Maximize Restore History

Download this file

filterbanktight.m    99 lines (77 with data), 2.4 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
function gtout=filterbanktight(g,a,L);
%FILTERBANKTIGHT Tight filters
% Usage: gt=filterbanktight(g,a);
%
% `filterabanktight(g,a)` computes the canonical tight filters of *g* for a
% channel subsampling rate of *a* (hop-size).
%
% The input and output format of the filters *g* are described in the
% help of |filterbank|.
%
% `filterabanktight(g,a,L)` computes canonical tight filters for a system
% of length *L*. If *L* is not specified, the shortest possible transform
% length is choosen.
%
% See also: filterbank, filterbankdual, ufilterbank, ifilterbank
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
[g,info]=filterbankwin(g,a,L,'normal');
M=info.M;
if (~isempty(L)) && (L~=filterbanklength(L,a))
error(['%s: Specified length L is incompatible with the length of ' ...
'the time shifts.'],upper(mfilename));
end;
[g,info]=filterbankwin(g,a,L,'normal');
M=info.M;
if all(a==a(1))
% Uniform filterbank, use polyphase representation
if isempty(L)
error('%s: You need to specify L.',upper(mfilename));
end;
a=a(1);
% G1 is done this way just so that we can determine the data type.
G1=comp_transferfunction(g{1},L);
thisclass=assert_classname(G1);
G=zeros(L,M,thisclass);
G(:,1)=G1;
for ii=2:M
G(:,ii)=comp_transferfunction(g{ii},L);
end;
N=L/a;
H=zeros(a,M,thisclass);
gt=zeros(N,M,thisclass);
for w=0:N-1
idx = mod(w-(0:a-1)*N,L)+1;
H = G(idx,:);
[U,S,V]=svd(H,'econ');
H=U*V';
gt(idx,:)=H;
end;
gt=ifft(gt)*sqrt(a);
if isreal(g)
gt=real(gt);
end;
gtout=cell(1,M);
for m=1:M
gtout{m}=cast(gt(:,m),thisclass);
end;
else
if info.ispainless
Fsqrt=sqrt(filterbankresponse(g,a,L));
gdout=cell(1,M);
for m=1:M
thisgt=struct();
thisgt.H=comp_transferfunction(g{m},L)./Fsqrt;
thisgt.foff=0;
thisgt.realonly=0;
thisgt.delay=0;
gtout{m}=thisgt;
end;
else
error(['%s: The canonical dual frame of this system is not a ' ...
'filterbank. You must call an iterative ' ...
'method to perform the desired inverstion. Please see ' ...
'FRANAITER or FRSYNITER.'],upper(mfilename));
end;
end;