annotate 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
rev   line source
daniele@167 1 function dico = dico_decorr_symetric(dico, mu, amp)
daniele@167 2 %DICO_DECORR decorrelate a dictionary
daniele@167 3 % Parameters:
daniele@167 4 % dico: the dictionary
daniele@167 5 % mu: the coherence threshold
daniele@167 6 % amp: the amplitude coefficients, only used to decide which atom to
daniele@167 7 % project
daniele@167 8 %
daniele@167 9 % Result:
daniele@167 10 % dico: a dictionary close to the input one with coherence mu.
daniele@167 11
daniele@167 12 eps = 1e-6; % define tolerance for normalisation term alpha
daniele@167 13
daniele@167 14 % convert mu to the to the mean direction
daniele@167 15 theta = acos(mu)/2;
daniele@167 16 ctheta = cos(theta);
daniele@167 17 stheta = sin(theta);
daniele@167 18
daniele@167 19 % compute atom weights
daniele@167 20 % if nargin > 2
daniele@167 21 % rank = sum(amp.*amp, 2);
daniele@167 22 % else
daniele@167 23 % rank = randperm(length(dico));
daniele@167 24 % end
daniele@167 25
daniele@167 26 % several decorrelation iterations might be needed to reach global
daniele@167 27 % coherence mu. niter can be adjusted to needs.
daniele@167 28 niter = 1;
daniele@167 29 while niter < 5 && ...
daniele@167 30 max(max(abs(dico'*dico -eye(length(dico))))) > mu + eps
daniele@167 31 % find pairs of high correlation atoms
daniele@167 32 colors = dico_color(dico, mu);
daniele@167 33
daniele@167 34 % iterate on all pairs
daniele@167 35 nbColors = max(colors);
daniele@167 36 for c = 1:nbColors
daniele@167 37 index = find(colors==c);
daniele@167 38 if numel(index) == 2
daniele@167 39 if dico(:,index(1))'*dico(:,index(2)) > 0
daniele@167 40 %build the basis vectors
daniele@167 41 v1 = dico(:,index(1))+dico(:,index(2));
daniele@167 42 v1 = v1/norm(v1);
daniele@167 43 v2 = dico(:,index(1))-dico(:,index(2));
daniele@167 44 v2 = v2/norm(v2);
daniele@167 45
daniele@167 46 dico(:,index(1)) = ctheta*v1+stheta*v2;
daniele@167 47 dico(:,index(2)) = ctheta*v1-stheta*v2;
daniele@167 48 else
daniele@167 49 v1 = dico(:,index(1))-dico(:,index(2));
daniele@167 50 v1 = v1/norm(v1);
daniele@167 51 v2 = dico(:,index(1))+dico(:,index(2));
daniele@167 52 v2 = v2/norm(v2);
daniele@167 53
daniele@167 54 dico(:,index(1)) = ctheta*v1+stheta*v2;
daniele@167 55 dico(:,index(2)) = -ctheta*v1+stheta*v2;
daniele@167 56 end
daniele@167 57 end
daniele@167 58 end
daniele@167 59 niter = niter+1;
daniele@167 60 end
daniele@167 61 end
daniele@167 62