annotate DL/two-step DL/dico_decorr.m @ 226:2124e4884765 danieleb

Update to reflect default branch.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 12 Apr 2012 13:59:59 +0100
parents a4d0977d4595
children
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
danieleb@156 12 eps = 1e-6; % define tolerance for normalisation term alpha
danieleb@156 13
ivan@152 14 % compute atom weights
ivan@152 15 if nargin > 2
ivan@152 16 rank = sum(amp.*amp, 2);
ivan@152 17 else
ivan@152 18 rank = randperm(length(dico));
ivan@152 19 end
ivan@152 20
ivan@152 21 % several decorrelation iterations might be needed to reach global
ivan@152 22 % coherence mu. niter can be adjusted to needs.
ivan@152 23 niter = 1;
ivan@152 24 while niter < 5 && ...
danieleb@156 25 max(max(abs(dico'*dico -eye(length(dico))))) > mu + eps
ivan@152 26 % find pairs of high correlation atoms
ivan@152 27 colors = dico_color(dico, mu);
ivan@152 28
ivan@152 29 % iterate on all pairs
ivan@152 30 nbColors = max(colors);
ivan@152 31 for c = 1:nbColors
ivan@152 32 index = find(colors==c);
ivan@152 33 if numel(index) == 2
ivan@152 34 % decide which atom to change (the one with lowest weight)
ivan@152 35 if rank(index(1)) < rank(index(2))
ivan@152 36 index = fliplr(index);
ivan@152 37 end
ivan@152 38
ivan@152 39 % update the atom
ivan@152 40 corr = dico(:,index(1))'*dico(:,index(2));
danieleb@156 41 alpha = sqrt((1-mu*mu)/(1-corr^2+eps));
ivan@152 42 beta = corr*alpha-mu*sign(corr);
ivan@152 43 dico(:,index(2)) = alpha*dico(:,index(2))...
ivan@152 44 -beta*dico(:,index(1));
ivan@152 45 end
ivan@152 46 end
ivan@152 47 niter = niter+1;
ivan@152 48 end
ivan@152 49 end
ivan@152 50