# HG changeset patch # User Daniele Barchiesi # Date 1316525234 -3600 # Node ID 8324c7ea660228ae2e63fb34a1c76127523fb24c # Parent 1495bdfa13e96d5a39e106d7868e39614a4a26c4 Added symmetric de-correlation function, modified target de-correlation in test function. diff -r 1495bdfa13e9 -r 8324c7ea6602 DL/two-step DL/SMALL_two_step_DL.m --- a/DL/two-step DL/SMALL_two_step_DL.m Mon Sep 19 14:53:23 2011 +0100 +++ b/DL/two-step DL/SMALL_two_step_DL.m Tue Sep 20 14:27:14 2011 +0100 @@ -116,7 +116,7 @@ dico = normcols(dico); switch DL.param.decFcn case 'mailhe' - dico = dico_decorr(dico, mu, solver.solution); + dico = dico_decorr_symetric(dico, mu, solver.solution); case 'tropp' [n m] = size(dico); dico = grassmannian(n,m,[],[],[],dico,true); diff -r 1495bdfa13e9 -r 8324c7ea6602 DL/two-step DL/dico_decorr_symetric.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DL/two-step DL/dico_decorr_symetric.m Tue Sep 20 14:27:14 2011 +0100 @@ -0,0 +1,62 @@ +function dico = dico_decorr_symetric(dico, mu, amp) + %DICO_DECORR decorrelate a dictionary + % Parameters: + % dico: the dictionary + % mu: the coherence threshold + % amp: the amplitude coefficients, only used to decide which atom to + % project + % + % Result: + % dico: a dictionary close to the input one with coherence mu. + + eps = 1e-6; % define tolerance for normalisation term alpha + + % convert mu to the to the mean direction + theta = acos(mu)/2; + ctheta = cos(theta); + stheta = sin(theta); + + % compute atom weights + % if nargin > 2 + % rank = sum(amp.*amp, 2); + % else + % rank = randperm(length(dico)); + % end + + % several decorrelation iterations might be needed to reach global + % coherence mu. niter can be adjusted to needs. + niter = 1; + while niter < 5 && ... + max(max(abs(dico'*dico -eye(length(dico))))) > mu + eps + % find pairs of high correlation atoms + colors = dico_color(dico, mu); + + % iterate on all pairs + nbColors = max(colors); + for c = 1:nbColors + index = find(colors==c); + if numel(index) == 2 + if dico(:,index(1))'*dico(:,index(2)) > 0 + %build the basis vectors + v1 = dico(:,index(1))+dico(:,index(2)); + v1 = v1/norm(v1); + v2 = dico(:,index(1))-dico(:,index(2)); + v2 = v2/norm(v2); + + dico(:,index(1)) = ctheta*v1+stheta*v2; + dico(:,index(2)) = ctheta*v1-stheta*v2; + else + v1 = dico(:,index(1))-dico(:,index(2)); + v1 = v1/norm(v1); + v2 = dico(:,index(1))+dico(:,index(2)); + v2 = v2/norm(v2); + + dico(:,index(1)) = ctheta*v1+stheta*v2; + dico(:,index(2)) = -ctheta*v1+stheta*v2; + end + end + end + niter = niter+1; + end +end + diff -r 1495bdfa13e9 -r 8324c7ea6602 examples/SMALL_test_coherence.m --- a/examples/SMALL_test_coherence.m Mon Sep 19 14:53:23 2011 +0100 +++ b/examples/SMALL_test_coherence.m Tue Sep 20 14:27:14 2011 +0100 @@ -18,7 +18,8 @@ % Dependent parameters nActiveAtoms = fix(blockSize/100*percActiveAtoms); %number of active atoms epsilon = 1/sigma; %error constraint for sparse representation step (corresponds to noise applied to signals) -minCoherence = sqrt((dictSize-blockSize)/(blockSize*(dictSize-1))); %target coherence (based on coherence lower bound) +%minCoherence = sqrt((dictSize-blockSize)/(blockSize*(dictSize-1))); %target coherence (based on coherence lower bound) +minCoherence = 0.4; %target coherence % Initial dictionaries dctDict = dictionary('dct',blockSize,dictSize); @@ -167,28 +168,28 @@ minMu = sqrt((dictSize-blockSize)/(blockSize*(dictSize-1))); maxSNR = max(sigNoiseRatio); -figure, subplot(2,2,1) +figure, subplot(1,2,1) snrMat = buffer(sigNoiseRatio(1:9),3); bar(snrMat'); -title('SNR - KSVD Update') +title('Signal to noise ratio') xlabel('Initial dictionary') ylabel('SNR (dB)') -set(gca,'XTickLabel',{'data','dct','gabor'},'YLim',[0 maxSNR+1]); +set(gca,'XTickLabel',{'data','dct','gabor'}); legend('none','Mailhe','Tropp') grid on -subplot(2,2,2), grid on -snrMat = buffer(sigNoiseRatio(10:18),3); -bar(snrMat'); -title('SNR - Mailhe Update') -xlabel('Initial dictionary') -ylabel('SNR (dB)') -set(gca,'XTickLabel',{'data','dct','gabor'},'YLim',[0 maxSNR+1]); -legend('none','Mailhe','Tropp') -grid on +% subplot(2,2,2), grid on +% snrMat = buffer(sigNoiseRatio(10:18),3); +% bar(snrMat'); +% title('SNR - Mailhe Update') +% xlabel('Initial dictionary') +% ylabel('SNR (dB)') +% set(gca,'XTickLabel',{'data','dct','gabor'},'YLim',[0 maxSNR+1]); +% legend('none','Mailhe','Tropp') +% grid on -subplot(2,2,3), hold on, grid on -title('Coherence - KSVD Update') +subplot(1,2,2), hold on, grid on +title('Coherence') muMat = buffer(mu(1:9),3); line([0.5 3.5],[1 1],'Color','r'); bar(muMat'); @@ -198,13 +199,13 @@ ylabel('\mu') xlabel('Initial dictionary') -subplot(2,2,4), hold on, grid on -title('Coherence - Mailhe Update') -muMat = buffer(mu(10:18),3); -line([0.5 3.5],[1 1],'Color','r'); -bar(muMat'); -line([0.5 3.5],[minMu minMu],'Color','k'); -set(gca,'XTick',1:3,'XTickLabel',{'data','dct','gabor'},'YLim',[0 1.05]) -legend('\mu_{max}','none','Mailhe','Tropp','\mu_{min}') -ylabel('\mu') -xlabel('Initial dictionary') +% subplot(2,2,4), hold on, grid on +% title('Coherence - Mailhe Update') +% muMat = buffer(mu(10:18),3); +% line([0.5 3.5],[1 1],'Color','r'); +% bar(muMat'); +% line([0.5 3.5],[minMu minMu],'Color','k'); +% set(gca,'XTick',1:3,'XTickLabel',{'data','dct','gabor'},'YLim',[0 1.05]) +% legend('\mu_{max}','none','Mailhe','Tropp','\mu_{min}') +% ylabel('\mu') +% xlabel('Initial dictionary')