Mercurial > hg > smallbox
comparison DL/two-step DL/dico_decorr_symetric.m @ 195:d50f5bdbe14c luisf_dev
- Added SMALL_DL_test: simple DL showcase
- Added dico_decorr_symmetric: improved version of INK-SVD decorrelation step
- Debugged SMALL_learn, SMALLBoxInit and SMALL_two_step_DL
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Wed, 14 Mar 2012 14:42:52 +0000 |
parents | |
children | 69ce11724b1f |
comparison
equal
deleted
inserted
replaced
190:759313488e7b | 195:d50f5bdbe14c |
---|---|
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 max(max(abs(dico'*dico -eye(length(dico))))) > mu + 0.01 | |
30 % find pairs of high correlation atoms | |
31 colors = dico_color(dico, mu); | |
32 | |
33 % iterate on all pairs | |
34 nbColors = max(colors); | |
35 for c = 1:nbColors | |
36 index = find(colors==c); | |
37 if numel(index) == 2 | |
38 if dico(:,index(1))'*dico(:,index(2)) > 0 | |
39 %build the basis vectors | |
40 v1 = dico(:,index(1))+dico(:,index(2)); | |
41 v1 = v1/norm(v1); | |
42 v2 = dico(:,index(1))-dico(:,index(2)); | |
43 v2 = v2/norm(v2); | |
44 | |
45 dico(:,index(1)) = ctheta*v1+stheta*v2; | |
46 dico(:,index(2)) = ctheta*v1-stheta*v2; | |
47 else | |
48 v1 = dico(:,index(1))-dico(:,index(2)); | |
49 v1 = v1/norm(v1); | |
50 v2 = dico(:,index(1))+dico(:,index(2)); | |
51 v2 = v2/norm(v2); | |
52 | |
53 dico(:,index(1)) = ctheta*v1+stheta*v2; | |
54 dico(:,index(2)) = -ctheta*v1+stheta*v2; | |
55 end | |
56 end | |
57 end | |
58 niter = niter+1; | |
59 end | |
60 end | |
61 |