daniele@195
|
1 function dico = dico_decorr_symetric(dico, mu, amp)
|
daniele@195
|
2 %DICO_DECORR decorrelate a dictionary
|
daniele@195
|
3 % Parameters:
|
daniele@195
|
4 % dico: the dictionary
|
daniele@195
|
5 % mu: the coherence threshold
|
daniele@195
|
6 % amp: the amplitude coefficients, only used to decide which atom to
|
daniele@195
|
7 % project
|
daniele@195
|
8 %
|
daniele@195
|
9 % Result:
|
daniele@195
|
10 % dico: a dictionary close to the input one with coherence mu.
|
daniele@195
|
11
|
daniele@195
|
12 eps = 1e-6; % define tolerance for normalisation term alpha
|
daniele@195
|
13
|
daniele@195
|
14 % convert mu to the to the mean direction
|
daniele@195
|
15 theta = acos(mu)/2;
|
daniele@195
|
16 ctheta = cos(theta);
|
daniele@195
|
17 stheta = sin(theta);
|
daniele@195
|
18
|
daniele@195
|
19 % compute atom weights
|
daniele@195
|
20 % if nargin > 2
|
daniele@195
|
21 % rank = sum(amp.*amp, 2);
|
daniele@195
|
22 % else
|
daniele@195
|
23 % rank = randperm(length(dico));
|
daniele@195
|
24 % end
|
daniele@195
|
25
|
daniele@195
|
26 % several decorrelation iterations might be needed to reach global
|
daniele@195
|
27 % coherence mu. niter can be adjusted to needs.
|
daniele@195
|
28 niter = 1;
|
daniele@195
|
29 while max(max(abs(dico'*dico -eye(length(dico))))) > mu + 0.01
|
daniele@195
|
30 % find pairs of high correlation atoms
|
daniele@195
|
31 colors = dico_color(dico, mu);
|
daniele@195
|
32
|
daniele@195
|
33 % iterate on all pairs
|
daniele@195
|
34 nbColors = max(colors);
|
daniele@195
|
35 for c = 1:nbColors
|
daniele@195
|
36 index = find(colors==c);
|
daniele@195
|
37 if numel(index) == 2
|
daniele@195
|
38 if dico(:,index(1))'*dico(:,index(2)) > 0
|
daniele@195
|
39 %build the basis vectors
|
daniele@195
|
40 v1 = dico(:,index(1))+dico(:,index(2));
|
daniele@195
|
41 v1 = v1/norm(v1);
|
daniele@195
|
42 v2 = dico(:,index(1))-dico(:,index(2));
|
daniele@195
|
43 v2 = v2/norm(v2);
|
daniele@195
|
44
|
daniele@195
|
45 dico(:,index(1)) = ctheta*v1+stheta*v2;
|
daniele@195
|
46 dico(:,index(2)) = ctheta*v1-stheta*v2;
|
daniele@195
|
47 else
|
daniele@195
|
48 v1 = dico(:,index(1))-dico(:,index(2));
|
daniele@195
|
49 v1 = v1/norm(v1);
|
daniele@195
|
50 v2 = dico(:,index(1))+dico(:,index(2));
|
daniele@195
|
51 v2 = v2/norm(v2);
|
daniele@195
|
52
|
daniele@195
|
53 dico(:,index(1)) = ctheta*v1+stheta*v2;
|
daniele@195
|
54 dico(:,index(2)) = -ctheta*v1+stheta*v2;
|
daniele@195
|
55 end
|
daniele@195
|
56 end
|
daniele@195
|
57 end
|
daniele@195
|
58 niter = niter+1;
|
daniele@195
|
59 end
|
daniele@195
|
60 end
|
daniele@195
|
61
|