Mercurial > hg > smallbox
view examples/SMALL_test_coherence2.m @ 169:290cca7d3469 danieleb
Added dictionary decorrelation functions and test script for ICASSP paper.
author | Daniele Barchiesi <daniele.barchiesi@eecs.qmul.ac.uk> |
---|---|
date | Thu, 29 Sep 2011 09:46:52 +0100 |
parents | |
children | 68fb71aa5339 |
line wrap: on
line source
clc, clear, close all %% Parameteres % Dictionary learning parameters toolbox = 'TwoStepDL'; %dictionary learning toolbox dicUpdate = {'ksvd'}; %dictionary learning updates dicDecorr = {'none','mailhe','tropp','barchiesi'}; %dictionary decorrelation methods minCoherence = linspace(0.1,1,1); %coherence levels minCoherence = 0.4; %dicDecorr = {'barchiesi'}; iterNum = 20; %number of iterations epsilon = 1e-6; %tolerance level dictSize = 512; %number of atoms in the dictionary percActiveAtoms = 5; %percentage of active atoms % Test signal parameters signal = audio('music03_16kHz.wav'); %audio signal blockSize = 256; %size of audio frames overlap = 0.5; %overlap between consecutive frames % Dependent parameters nActiveAtoms = fix(blockSize/100*percActiveAtoms); %number of active atoms % Initial dictionaries dctDict = dictionary('dct',blockSize,dictSize); dctDict = dctDict.phi; gaborParam = struct('N',blockSize,'redundancyFactor',2,'wd',@rectwin); gaborDict = Gabor_Dictionary(gaborParam); initDicts = {[],dctDict,gaborDict}; initDicts = {[]}; %% Generate audio approximation problem signal = buffer(signal,blockSize,blockSize*overlap,@rectwin); SMALL.Problem.b = signal.S; SMALL.Problem.b1 = SMALL.Problem.b; % copy signals from training set b to test set b1 (needed for later functions) % omp2 sparse representation solver ompParam = struct('X',SMALL.Problem.b,'epsilon',epsilon,'maxatoms',nActiveAtoms); %parameters solver = SMALL_init_solver('ompbox','omp2',ompParam,false); %solver structure %% Test nDicUpdates = length(dicUpdate); %number of dictionary updates nDecorrAlgs = length(dicDecorr); %number of decorrelation algorithms nCorrLevels = length(minCoherence); %number of coherence levels nInitDicts = length(initDicts); %number of initial dictionaries SMALL.DL(nInitDicts,nCorrLevels,nDecorrAlgs,nDicUpdates) = SMALL_init_DL(toolbox); %create dictionary learning structures for iInitDicts=1:nInitDicts for iCorrLevels=1:nCorrLevels for iDecorrAlgs=1:nDecorrAlgs for iDicUpdates=1:nDicUpdates SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).toolbox = toolbox; SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).name = dicUpdate{iDicUpdates}; SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).profile = true; SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).param = ... struct( 'data',SMALL.Problem.b,... 'Tdata',nActiveAtoms,... 'dictsize',dictSize,... 'iternum',iterNum,... 'memusage','high',... 'solver',solver,... 'decFcn',dicDecorr{iDecorrAlgs},... 'coherence',minCoherence(iCorrLevels),... 'initdict',initDicts(iInitDicts)); SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates) = ... SMALL_learn(SMALL.Problem,SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates)); end end end end %% Evaluate coherence and snr of representation for the various methods sr = zeros(size(SMALL.DL)); %signal to noise ratio mu = zeros(size(SMALL.DL)); %coherence dic(size(SMALL.DL)) = dictionary; %initialise dictionary objects for iInitDict=1:nInitDicts for iCorrLevels=1:nCorrLevels for iDecorrAlgs=1:nDecorrAlgs for iDicUpdates=1:nDicUpdates %Sparse representation SMALL.Problem.A = SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).D; tempSolver = SMALL_solve(SMALL.Problem,solver); %calculate snr sr(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates) = ... snr(SMALL.Problem.b,SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).D*tempSolver.solution); %calculate mu dic(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates) = ... dictionary(SMALL.DL(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).D); mu(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates) = ... dic(iInitDicts,iCorrLevels,iDecorrAlgs,iDicUpdates).coherence; end end end end %% Plot results minMu = sqrt((dictSize-blockSize)/(blockSize*(dictSize-1))); %lowe bound on coherence initDictsNames = {'Data','DCT','Gabor'}; dicDecorrNames = {'K-SVD','INK-SVD','Grassmannian','New'}; lineStyles = {'ks-','kd-','ko-','k*-'}; for iInitDict=1:nInitDicts figure, hold on, grid on title([initDictsNames{iInitDict} ' Initialisation']); plot([1 1],[0 25],'k-'); for iDecorrAlgs=1:nDecorrAlgs plot(mu(iInitDicts,:,iDecorrAlgs,1),sr(iInitDicts,:,iDecorrAlgs,1),... lineStyles{iDecorrAlgs}); end plot([minMu minMu],[0 25],'k--') set(gca,'YLim',[0 25],'XLim',[0 1.4]); legend([{'\mu_{max}'},dicDecorrNames,{'\mu_{min}'}]); xlabel('\mu'); ylabel('SNR (dB)'); end