Mercurial > hg > smallbox
comparison DL/two-step DL/dico_decorr_symetric.m @ 167:8324c7ea6602 danieleb
Added symmetric de-correlation function, modified target de-correlation in test function.
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Tue, 20 Sep 2011 14:27:14 +0100 |
parents | |
children | 290cca7d3469 |
comparison
equal
deleted
inserted
replaced
166:1495bdfa13e9 | 167:8324c7ea6602 |
---|---|
1 function dico = dico_decorr_symetric(dico, mu, amp) | |
2 %DICO_DECORR decorrelate a dictionary | |
3 % Parameters: | |
4 % dico: the dictionary | |
5 % mu: the coherence threshold | |
6 % amp: the amplitude coefficients, only used to decide which atom to | |
7 % project | |
8 % | |
9 % Result: | |
10 % dico: a dictionary close to the input one with coherence mu. | |
11 | |
12 eps = 1e-6; % define tolerance for normalisation term alpha | |
13 | |
14 % convert mu to the to the mean direction | |
15 theta = acos(mu)/2; | |
16 ctheta = cos(theta); | |
17 stheta = sin(theta); | |
18 | |
19 % compute atom weights | |
20 % if nargin > 2 | |
21 % rank = sum(amp.*amp, 2); | |
22 % else | |
23 % rank = randperm(length(dico)); | |
24 % end | |
25 | |
26 % several decorrelation iterations might be needed to reach global | |
27 % coherence mu. niter can be adjusted to needs. | |
28 niter = 1; | |
29 while niter < 5 && ... | |
30 max(max(abs(dico'*dico -eye(length(dico))))) > mu + eps | |
31 % find pairs of high correlation atoms | |
32 colors = dico_color(dico, mu); | |
33 | |
34 % iterate on all pairs | |
35 nbColors = max(colors); | |
36 for c = 1:nbColors | |
37 index = find(colors==c); | |
38 if numel(index) == 2 | |
39 if dico(:,index(1))'*dico(:,index(2)) > 0 | |
40 %build the basis vectors | |
41 v1 = dico(:,index(1))+dico(:,index(2)); | |
42 v1 = v1/norm(v1); | |
43 v2 = dico(:,index(1))-dico(:,index(2)); | |
44 v2 = v2/norm(v2); | |
45 | |
46 dico(:,index(1)) = ctheta*v1+stheta*v2; | |
47 dico(:,index(2)) = ctheta*v1-stheta*v2; | |
48 else | |
49 v1 = dico(:,index(1))-dico(:,index(2)); | |
50 v1 = v1/norm(v1); | |
51 v2 = dico(:,index(1))+dico(:,index(2)); | |
52 v2 = v2/norm(v2); | |
53 | |
54 dico(:,index(1)) = ctheta*v1+stheta*v2; | |
55 dico(:,index(2)) = -ctheta*v1+stheta*v2; | |
56 end | |
57 end | |
58 end | |
59 niter = niter+1; | |
60 end | |
61 end | |
62 |