annotate DL/two-step DL/dico_decorr.m @ 234:c96880c0c47c

renamed file.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 19 Apr 2012 17:21:05 +0100
parents 485747bf39e0
children a4d0977d4595
rev   line source
ivan@152 1 function dico = dico_decorr(dico, mu, amp)
ivan@152 2 %DICO_DECORR decorrelate a dictionary
ivan@152 3 % Parameters:
ivan@152 4 % dico: the dictionary
ivan@152 5 % mu: the coherence threshold
ivan@152 6 % amp: the amplitude coefficients, only used to decide which atom to
ivan@152 7 % project
ivan@152 8 %
ivan@152 9 % Result:
ivan@152 10 % dico: a dictionary close to the input one with coherence mu.
ivan@152 11
ivan@152 12 % compute atom weights
ivan@152 13 if nargin > 2
ivan@152 14 rank = sum(amp.*amp, 2);
ivan@152 15 else
ivan@152 16 rank = randperm(length(dico));
ivan@152 17 end
ivan@152 18
ivan@152 19 % several decorrelation iterations might be needed to reach global
ivan@152 20 % coherence mu. niter can be adjusted to needs.
ivan@152 21 niter = 1;
ivan@152 22 while niter < 5 && ...
ivan@152 23 max(max(abs(dico'*dico -eye(length(dico))))) > mu + 10^-6
ivan@152 24 % find pairs of high correlation atoms
ivan@152 25 colors = dico_color(dico, mu);
ivan@152 26
ivan@152 27 % iterate on all pairs
ivan@152 28 nbColors = max(colors);
ivan@152 29 for c = 1:nbColors
ivan@152 30 index = find(colors==c);
ivan@152 31 if numel(index) == 2
ivan@152 32 % decide which atom to change (the one with lowest weight)
ivan@152 33 if rank(index(1)) < rank(index(2))
ivan@152 34 index = fliplr(index);
ivan@152 35 end
ivan@152 36
ivan@152 37 % update the atom
ivan@152 38 corr = dico(:,index(1))'*dico(:,index(2));
ivan@152 39 alpha = sqrt((1-mu*mu)/(1-corr*corr));
ivan@152 40 beta = corr*alpha-mu*sign(corr);
ivan@152 41 dico(:,index(2)) = alpha*dico(:,index(2))...
ivan@152 42 -beta*dico(:,index(1));
ivan@152 43 end
ivan@152 44 end
ivan@152 45 niter = niter+1;
ivan@152 46 end
ivan@152 47 end
ivan@152 48