comparison DL/two-step DL/dico_decorr.m @ 152:485747bf39e0 ivand_dev

Two step dictonary learning - Integration of the code for dictionary update and dictionary decorrelation from Boris Mailhe
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Thu, 28 Jul 2011 15:49:32 +0100
parents
children a4d0977d4595
comparison
equal deleted inserted replaced
149:fec205ec6ef6 152:485747bf39e0
1 function dico = dico_decorr(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 % compute atom weights
13 if nargin > 2
14 rank = sum(amp.*amp, 2);
15 else
16 rank = randperm(length(dico));
17 end
18
19 % several decorrelation iterations might be needed to reach global
20 % coherence mu. niter can be adjusted to needs.
21 niter = 1;
22 while niter < 5 && ...
23 max(max(abs(dico'*dico -eye(length(dico))))) > mu + 10^-6
24 % find pairs of high correlation atoms
25 colors = dico_color(dico, mu);
26
27 % iterate on all pairs
28 nbColors = max(colors);
29 for c = 1:nbColors
30 index = find(colors==c);
31 if numel(index) == 2
32 % decide which atom to change (the one with lowest weight)
33 if rank(index(1)) < rank(index(2))
34 index = fliplr(index);
35 end
36
37 % update the atom
38 corr = dico(:,index(1))'*dico(:,index(2));
39 alpha = sqrt((1-mu*mu)/(1-corr*corr));
40 beta = corr*alpha-mu*sign(corr);
41 dico(:,index(2)) = alpha*dico(:,index(2))...
42 -beta*dico(:,index(1));
43 end
44 end
45 niter = niter+1;
46 end
47 end
48