# HG changeset patch # User Ivan Damnjanovic lnx # Date 1314788539 -3600 # Node ID f42aa8bcb82fe495edc1bb8447c9bf023e2bf661 # Parent b14209313ba490b95870b113b02da10bae4470c3 debug and clean the SMALLbox Problems code diff -r b14209313ba4 -r f42aa8bcb82f DL/Majorization Minimization DL/wrapper_mm_solver.m --- a/DL/Majorization Minimization DL/wrapper_mm_solver.m Mon Aug 22 11:46:35 2011 +0100 +++ b/DL/Majorization Minimization DL/wrapper_mm_solver.m Wed Aug 31 12:02:19 2011 +0100 @@ -33,7 +33,7 @@ if isfield(param, 'to') to = param.to; else - to = .1+svds(A,1); + to = .1+(svds(A,1))^2; end % lambda - Lagrangian multiplier. (regulates shrinkage) @@ -65,7 +65,7 @@ if isfield(param, 'map') map = param.map; else - map = 1; + map = 0; end diff -r b14209313ba4 -r f42aa8bcb82f Problems/AMT_reconstruct.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Problems/AMT_reconstruct.m Wed Aug 31 12:02:19 2011 +0100 @@ -0,0 +1,117 @@ +function reconstructed=AMT_reconstruct(V, Problem) +%% Reconstruction of midi file from representation in the given dictionary +% +% SMALL_midiGenerate is a part of SMALLbox and can be use to reconstruct +% a midi file given representation of the training set (V) in the +% dictionary Problem.A. +% Output is reconstructed structure with two fields: +% - reconstructed.notes - matrix with transcribed notes +% - reconstructed.midi - midi representation of transcription + +% +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2009 Ivan Damnjanovic. +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2 of the +% License, or (at your option) any later version. See the file +% COPYING included with this distribution for more information. +%% +U=Problem.A; % Dictionary used for representation +fs=Problem.fs; % Sampling rate +f=Problem.f; % vector of frequencies at wihch spectrogram is computed + +ts=(Problem.windowSize*(1-Problem.overlap))/fs; %size of an analysis frame in seconds + +%% +% Components pitch estimation using modified SWIPE algorithm by Arthuro +% Camacho +% +% Columns of matrix U are spectrograms of the notes learned from the +% training set. We are estimating pitches of these notes by also +% restricting pitch values to the one of the 88 piano notes. + +pitch=zeros(size(U,2),1); + +for i=1:size(U,2) + + pitch(i) = SMALL_swipe(U(:,i),fs, f, [27.50 8192], 1/12); + +end + +%% +% If some of columns of U have the same pitch, their contribution to the +% score (matrix V) is summed. + +[Ps,idx]=sort(pitch); +ndp=1; +Pd(ndp)=Ps(1); +Vnew(ndp,:)=V(idx(1),:); +for i=2:88 + if Ps(i)> Ps(i-1) + + ndp=ndp+1; + Vnew(ndp,:)=V(idx(i),:); + Pd(ndp)=Ps(i); + + else + Vnew(ndp,:)=Vnew(ndp,:)+V(idx(i),:); + end +end +%% +% Generate midi matrix + +midx=0; +for i=1:ndp + + % Threshold for finding onsets and offsets of notes + + thr=mean(Vnew(i,:));%+std(Vnew(i,:)); + + if(Pd(i)~=0) + for j=1:size(Vnew,2) + if Vnew(i,j)1) + if (Vnew(i,j-1)==1) + try + M(midx,6)=(j-1)*ts; + if (M(midx,6)-M(midx,5))<2*ts + midx=midx-1; + end + catch + pause; + end + end + end + else + Vnew(i,j)=1; + if(j>1) + if (Vnew(i,j-1)==0) + midx=midx+1; + M(midx,1)=1; + M(midx,2)=1; + M(midx,3)=69 +round( 12 *log2(Pd(i)/440)); + M(midx,4)=80; + M(midx,5)=(j-1)*ts; + end + else + midx=midx+1; + M(midx,1)=1; + M(midx,2)=1; + M(midx,3)=69 + round(12 *log2(Pd(i)/440)); + M(midx,4)=80; + M(midx,5)=0; + end + end + end + if M(midx,6)==0 + M(midx,6)=(j-1)*ts; + end + end +end + +M=sortrows(M,5); +reconstructed.notes=M; +reconstructed.midi = matrix2midi(M); diff -r b14209313ba4 -r f42aa8bcb82f Problems/AudioDeclipping_reconstruct.m --- a/Problems/AudioDeclipping_reconstruct.m Mon Aug 22 11:46:35 2011 +0100 +++ b/Problems/AudioDeclipping_reconstruct.m Wed Aug 31 12:02:19 2011 +0100 @@ -1,8 +1,15 @@ -function reconstructed=AudioDeclipping_reconstruct(y, Problem, SparseDict) +function reconstructed = AudioDeclipping_reconstruct(y, Problem) %% Audio declipping Problem reconstruction function % % This reconstruction function is using sparse representation y % in dictionary Problem.A to reconstruct declipped audio. +% The output structure has following fields: +% audioAllSamples - signal with all samples taken from reconstructed +% signal +% audioOnlyClipped - only clipped samples are reconstructed, +% others are taken from original signal +% snrAll - psnr of whole signal +% snrMiss - psnr of the reconstructed clipped samples % % [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an % evaluation framework for sparse representations and dictionary diff -r b14209313ba4 -r f42aa8bcb82f Problems/AudioDenoise_reconstruct.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Problems/AudioDenoise_reconstruct.m Wed Aug 31 12:02:19 2011 +0100 @@ -0,0 +1,53 @@ +function reconstructed=AudioDenoise_reconstruct(y, Problem) +%% Audio denoising Problem reconstruction function +% +% This reconstruction function is using sparse representation y +% in dictionary Problem.A to reconstruct denoised audio. +% The output structre has following fields: +% audio - denoised audio signal +% psnr - psnr of the reconstructed audio signal +% +% [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an +% evaluation framework for sparse representations and dictionary +% learning algorithms," V. Vigneron et al. (Eds.): LVA/ICA 2010, +% Springer-Verlag, Berlin, Germany, LNCS 6365, pp. 418-425 + +% +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2011 Ivan Damnjanovic. +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2 of the +% License, or (at your option) any later version. See the file +% COPYING included with this distribution for more information. +%% + +windowSize = Problem.windowSize; +overlap = Problem.overlap; +ws = Problem.ws(windowSize); +wa = Problem.wa(windowSize); + +A = Problem.A; + +orig = Problem.Original; +noisy = Problem.Noisy; + + +% reconstruct audio frames + +xFrames = diag(ws)*(A*y); +wNormFrames = (ws.*wa)'*ones(1,size(xFrames,2)); + +% overlap and add + +rec = col2imstep(xFrames, size(noisy), [windowSize 1], [windowSize*overlap 1]); +wNorm = col2imstep(wNormFrames, size(noisy), [windowSize 1], [windowSize*overlap 1]); +wNorm(find(wNorm==0)) = 1; +recN = rec./wNorm; + +%% output structure image+psnr %% +reconstructed.audio = recN; +reconstructed.psnr = 20*log10(sqrt(numel(orig)) / norm(orig - reconstructed.audio)); + +end \ No newline at end of file diff -r b14209313ba4 -r f42aa8bcb82f Problems/ImageDenoise_reconstruct.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Problems/ImageDenoise_reconstruct.m Wed Aug 31 12:02:19 2011 +0100 @@ -0,0 +1,66 @@ +function reconstructed=ImageDenoise_reconstruct(y, Problem, SparseDict) +%% Image Denoising Problem reconstruction function +% +% This reconstruction function is using sparse representation y +% in dictionary Problem.A to reconstruct the patches of the denoised +% image. + +% +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2009 Ivan Damnjanovic. +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2 of the +% License, or (at your option) any later version. See the file +% COPYING included with this distribution for more information. +%% + + +% stepsize % +if (isfield(Problem,'stepsize')) + stepsize = Problem.stepsize; + if (numel(stepsize)==1) + stepsize = ones(1,2)*stepsize; + end +else + stepsize = ones(1,2); +end +if (any(stepsize<1)) + error('Invalid step size.'); +end + +% lambda % +if (isfield(Problem,'lambda')) + lambda = Problem.lambda; +else + lambda = Problem.maxval/(10*Problem.sigma); +end +if exist('SparseDict','var')&&(SparseDict==1) + if issparse(Problem.A) + A = Problem.A; + else + A = sparse(Problem.A); + end + cl_samp=add_dc(dictsep(Problem.basedict,A,y), Problem.b1dc,'columns'); +else + cl_samp=add_dc(Problem.A*y, Problem.b1dc,'columns'); +end +% combine the patches into reconstructed image +cl_im=col2imstep(cl_samp, size(Problem.Noisy), Problem.blocksize); + +cnt = countcover(size(Problem.Noisy),Problem.blocksize,stepsize); + +im = (cl_im+lambda*Problem.Noisy)./(cnt + lambda); +% y(y~=0)=1; +% numD=sum(y,2); +% nnzy=sum(y,1); +% figure(200);plot(sort(numD)); +% figure(201);plot(sort(nnzy)); +[v.RMSErn, v.RMSEcd, v.rn_im, v.cd_im]=SMALL_vmrse_type2(Problem.Original, Problem.Noisy, im); +%% output structure image+psnr %% +reconstructed.Image=im; +reconstructed.psnr = 20*log10(Problem.maxval * sqrt(numel(Problem.Original(:))) / norm(Problem.Original(:)-im(:))); +reconstructed.vmrse=v; +reconstructed.ssim=SMALL_ssim_index(Problem.Original, im); +end \ No newline at end of file diff -r b14209313ba4 -r f42aa8bcb82f Problems/generateAMTProblem.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Problems/generateAMTProblem.m Wed Aug 31 12:02:19 2011 +0100 @@ -0,0 +1,91 @@ +function data = generateAMTProblem(nfft, windowSize, overlap) +%% Generate Automatic Music Transcription Problem +% +% generateAMT_Learning_Problem is a part of the SMALLbox and generates +% a problem that can be used for comparison of Dictionary Learning/Sparse +% Representation techniques in automatic music transcription scenario. +% The function prompts a user for an audio file (mid, wav, mat) reads it +% and generates a spectrogram given fft size (default nfft=4096), analysis +% window size (windowSize=2822), and analysis window overlap (overlap = +% 0.5). +% +% The output of the function is stucture with following fields: +% b - matrix with magnitudes of the spectrogram +% f - vector of frequencies at wihch spectrogram is computed +% windowSize - analysis window size +% overlap - analysis window overlap +% fs - sampling frequency +% m - number of frequenciy points in spectrogram +% n - number of time points in the spectrogram +% p - number of dictionary elements to be learned (eg 88 for piano) +% notesOriginal - notes of the original audio to be used for +% comparison (if midi of the original exists) +% name - name of the audio file to transcribe + +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2009 Ivan Damnjanovic. +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2 of the +% License, or (at your option) any later version. See the file +% COPYING included with this distribution for more information. +% +%% +FS=filesep; +if ~ exist( 'nfft', 'var' ) || isempty(nfft), nfft = 4096; end +if ~ exist( 'windowSize', 'var' ) || isempty(windowSize), windowSize = 2822; end +if ~ exist( 'overlap', 'var' ) || isempty(overlap), overlap = 0.5; end + +%% +%ask for file name +TMPpath=pwd; +[pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m')); +cd([pathstr1,FS,'data',FS,'audio']); +[filename,pathname] = uigetfile({'*.mat; *.mid; *.wav'},'Select a file to transcribe'); +[pathstr, name, ext, versn] = fileparts(filename); +data.name=name; + +data.notesOriginal=[]; + +if strcmp(ext,'.mid') + midi=readmidi(filename); + data.notesOriginal=midiInfo(midi); + y=midi2audio(midi); + wavwrite(y, 44100, 16, 'temp.wav'); + [x.signal, x.fs, x.nbits]=wavread('temp.wav'); + delete('temp.wav'); +elseif strcmp(ext,'.wav') + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'midi']); + filename1=[name, '.mid']; + if exist(filename1, 'file') + midi=readmidi(filename1); + data.notesOriginal=midiInfo(midi); + end + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'wav']); + [x.signal, x.fs, x.nbits]=wavread(filename); +else + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'midi']); + filename1=[name, '.mid']; + if exist(filename1, 'file') + midi=readmidi(filename1); + data.notesOriginal=midiInfo(midi); + end + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'mat']); + x=load([pathname,filename]); +end +%% +[X, frX]=spectrogram(x.signal, hanning(windowSize), overlap*windowSize, nfft, x.fs); +%% +data.b=abs(X); +data.f=frX; +data.windowSize=windowSize; +data.overlap=overlap; +data.fs=x.fs; +data.m=size(X,1); +data.n=size(X,2); + +data.p=88; %number of dictionary elements (ie notes to recover) +cd(TMPpath); + +end diff -r b14209313ba4 -r f42aa8bcb82f Problems/generateAudioDeclippingProblem.m --- a/Problems/generateAudioDeclippingProblem.m Mon Aug 22 11:46:35 2011 +0100 +++ b/Problems/generateAudioDeclippingProblem.m Wed Aug 31 12:02:19 2011 +0100 @@ -5,6 +5,35 @@ % Audio declipping is a problem proposed in Audio Inpaining Toolbox and % in [2]. % +% The function takes as an optional input +% soundfile - name of the file +% clippingLevel - (default 0.6) +% windowSize - 1D frame size (eg 512) +% overlap - ammount of overlaping frames between 0 and 1 +% wa,ws,wd - analisys, synthesis and dictionary window functions +% +% Dict_fun - function to be used to generate dictionary +% redundancyFactor - overcompletness of dictionary (default 2) +% +% The function outputs the structure with following fields: +% original - original signal +% clipped - clipped signal +% clipMask - mask indicating clipped samples +% clippingLevel - (default 0.6) +% Upper_Limit - maximum value of original data +% fs - sample rate of the original signal in Hertz +% nbits - the number of bits per sample +% sigma - added noise level +% B - dictionary to be used for sparse representation +% M - measurement matrix (non-clipped data in b) +% b - matrix of clipped frames +% m - size od dictionary atom +% n - number of frames to be represented +% p - number of atoms in dictionary +% windowSize - 1D frame size (eg 512) +% overlap - ammount of overlaping frames between 0 and 1 +% wa,ws, wd - analisys, synthesis and dictionary window functions +% % [1] I. Damnjanovic, M. E. P. Davies, and M. P. Plumbley "SMALLbox - an % evaluation framework for sparse representations and dictionary % learning algorithms," V. Vigneron et al. (Eds.): LVA/ICA 2010, @@ -103,7 +132,7 @@ data.fs = x.fs; data.nbits = x.nbits; -data.Upper_Limit = max(solutiondata.XClean); +data.Upper_Limit = max(solutionData.xClean); [data.m, data.n] = size(x_clip); data.p = windowSize*redundancyFactor; %number of dictionary elements diff -r b14209313ba4 -r f42aa8bcb82f Problems/generateAudioDenoiseProblem.m --- a/Problems/generateAudioDenoiseProblem.m Mon Aug 22 11:46:35 2011 +0100 +++ b/Problems/generateAudioDenoiseProblem.m Wed Aug 31 12:02:19 2011 +0100 @@ -1,20 +1,40 @@ -function data=generateAudioDenoiseProblem(au, trainnum, blocksize, dictsize, overlap, sigma, gain, maxval, initdict); -%% Audio Denoising Problem - needs revision, not yet finalised +function data = generateAudioDenoiseProblem(soundfile, sigma, windowSize,... + overlap, wa, ws, trainnum, redundancyFactor, initdict) +%% Audio Denoising Problem % % generateAudioDenoiseProblem is part of the SMALLbox and generate a % problem for comaprison of Dictionary Learning/Sparse Representation -% techniques in audio denoising scenario. It is based on KSVD image -% denoise demo by Ron Rubinstein (see bellow). -% The fuction takes as an optional input -% au - audio samples to be denoised -% trainnum - number of frames for training -% blocksize - 1D frame size (eg 512) -% dictsize - number of atoms to be trained -% overlap - ammount of overlaping frames between 0 and 1 +% techniques in audio denoising scenario. +% +% The function takes as an optional input +% soundfile - name of the file +% sigma - noise level (dB) +% windowSize - 1D frame size (eg 512) +% overlap - ammount of overlaping frames between 0 and 1 +% wa,ws - analisys and synthesis window functions +% +% trainnum - number of frames for training +% redundancyFactor - overcompletness of dictionary (default 2) +% initdict - initial dictionary % +% The function outputs the structure with following fields: +% Original - original signal +% Noisy - signal with added noise +% fs - sample rate of the original signal in Hertz +% nbits - the number of bits per sample +% sigma - added noise level +% b - matrix of training samples for dictionary learning +% b1 - matrix containing all frames for reconstruction step +% m - size od dictionary atom +% n - number of frames for training +% p - number of atoms in dictionary +% windowSize - 1D frame size (eg 512) +% overlap - ammount of overlaping frames between 0 and 1 +% wa,ws - analisys and synthesis window functions +% initdict - initial dictionary % Centre for Digital Music, Queen Mary, University of London. -% This file copyright 2010 Ivan Damnjanovic. +% This file copyright 2011 Ivan Damnjanovic. % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -30,67 +50,69 @@ disp(' '); FS=filesep; -if ~ exist( 'sigma', 'var' ) || isempty(sigma), sigma = 26.74; end -if ~ exist( 'gain', 'var' ) || isempty(gain), gain = 1.15; end -if ~ exist( 'initdict', 'var' ) || isempty(initdict), initdict = 'odct'; end -if ~ exist( 'overlap', 'var' ) || isempty(overlap), overlap = 15/16; end %% prompt user for wav file %% %ask for file name TMPpath=pwd; -if ~ exist( 'au', 'var' ) || isempty(au) +if ~ exist( 'soundfile', 'var' ) || isempty(soundfile) + %ask for file name [pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m')); - cd([pathstr1,FS,'data',FS,'audio',FS,'wav']); - [filename,pathname] = uigetfile({'*.wav;'},'Select a wav file'); + cd([pathstr1,FS,'data',FS,'audio']); + [filename,pathname] = uigetfile({'*.mat; *.mid; *.wav'},'Select a file to transcribe'); [pathstr, name, ext, versn] = fileparts(filename); data.name=name; - - au = wavread(filename); - au = mean(au,2); % turn it into mono. -end; -if ~ exist( 'maxval', 'var' ) || isempty(maxval), maxval = max(au); end -%% generate noisy audio %% - -disp(' '); -disp('Generating noisy audio...'); -sigma = max(au)/10^(sigma/20); -n = randn(size(au)) .* sigma; -aunoise = au + n;% here we can load noise audio if available - % for example: wavread('icassp06_x.wav');% - - + if strcmp(ext,'.mid') + midi=readmidi(filename); +% data.notesOriginal=midiInfo(midi); + y=midi2audio(midi); + wavwrite(y, 44100, 16, 'temp.wav'); + [x.signal, x.fs, x.nbits]=wavread('temp.wav'); + delete('temp.wav'); + elseif strcmp(ext,'.wav') +% cd([pathstr1,FS, 'data', FS, 'audio', FS, 'midi']); +% filename1=[name, '.mid']; +% if exist(filename1, 'file') +% midi=readmidi(filename1); +% data.notesOriginal=midiInfo(midi); +% end + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'wav']); + [x.signal, x.fs, x.nbits]=wavread(filename); + else +% cd([pathstr1,FS, 'data', FS, 'audio', FS, 'midi']); +% filename1=[name, '.mid']; +% if exist(filename1, 'file') +% midi=readmidi(filename1); +% data.notesOriginal=midiInfo(midi); +% end + cd([pathstr1,FS, 'data', FS, 'audio', FS, 'mat']); + x=load([pathname,filename]); + end +else + [x.signal, x.fs, x.nbits]=wavread(soundfile); + [pathstr, name, ext, versn] = fileparts(soundfile); + data.name=name; +end %% set parameters %% +if ~ exist( 'sigma', 'var' ) || isempty(sigma), sigma = 0.2; end -x = aunoise; -if ~ exist( 'blocksize', 'var' ) || isempty(blocksize),blocksize = 512;end -if ~ exist( 'dictsize', 'var' ) || isempty(dictsize), dictsize = 2048;end +if ~ exist( 'windowSize', 'var' ) || isempty(windowSize), windowSize = 256;end +if ~ exist( 'overlap', 'var' ) || isempty(overlap), overlap = 0.5; end +if ~ exist( 'wa', 'var' ) || isempty(wa), wa = @wSine; end % Analysis window +if ~ exist( 'ws', 'var' ) || isempty(ws), ws = @wSine; end % Synthesis window -if ~ exist( 'trainnum', 'var' ) || isempty(trainnum),trainnum = (size(x,1)-blocksize+1);end +if ~ exist( 'redundancyFactor', 'var' ) || isempty(windowSize),... + redundancyFactor = 2;end +if ~ exist( 'initdict', 'var' ) || isempty(initdict),... + initdict = 'odct'; end +if ~ exist( 'trainnum', 'var' ) || isempty(trainnum), ... + trainnum = 16*redundancyFactor*windowSize;end - - - -p=1; - - -% -% msgdelta = 5; -% -% verbose = 't'; -% if (msgdelta <= 0) -% verbose=''; -% msgdelta = -1; -% end -% -% -% % initial dictionary % -% if (strcmpi(initdict,'odct')) - initdict = odctndict(blocksize,dictsize,p); + initdict = odctndict(windowSize, redundancyFactor*windowSize, 1); elseif (strcmpi(initdict,'data')) clear initdict; % causes initialization using random examples else @@ -98,45 +120,31 @@ end if exist( 'initdict', 'var' ) - initdict = initdict(:,1:dictsize); + initdict = initdict(:,1:redundancyFactor*windowSize); end -% noise mode % -% if (isfield(params,'noisemode')) -% switch lower(params.noisemode) -% case 'psnr' -% sigma = maxval / 10^(params.psnr/20); -% case 'sigma' -% sigma = params.sigma; -% otherwise -% error('Invalid noise mode specified'); -% end -% elseif (isfield(params,'sigma')) -% sigma = params.sigma; -% elseif (isfield(params,'psnr')) -% sigma = maxval / 10^(params.psnr/20); -% else -% error('Noise strength not specified'); -% end - -% params.Edata = sqrt(prod(blocksize)) * sigma * gain; % target error for omp -% params.codemode = 'error'; -% -% params.sigma = sigma; -% params.noisemode = 'sigma'; -% -% -% % make sure test data is not present in params -% if (isfield(params,'testdata')) -% params = rmfield(params,'testdata'); -% end - - %%%% create training data %%% +%% generate noisy audio %% -X = buffer( x(1:trainnum),blocksize, overlap*blocksize); +disp(' '); +disp('Generating noisy audio...'); +x.signal = x.signal/max(abs(x.signal(:)))*0.99999; +n = randn(size(x.signal)) .* sigma; + +xnoise = x.signal + n;% here we can load noise audio if available + % for example: wavread('icassp06_x.wav');% + + + + +X = im2colstep(xnoise,[windowSize 1],[overlap*windowSize 1]); +X = diag(wa(windowSize)) * X; + + + + % remove dc in blocks to conserve memory % % bsize = 2000; @@ -144,17 +152,32 @@ % blockids = i : min(i+bsize-1,size(X,2)); % X(:,blockids) = remove_dc(X(:,blockids),'columns'); % end -data.Original = au; -data.Noisy = aunoise; -data.b = X; -data.m = size(X,1); -data.n = size(X,2); -data.p = dictsize; -data.blocksize=blocksize; +data.Original = x.signal; +data.Noisy = xnoise; +data.fs = x.fs; +data.nbits = x.nbits; + data.sigma = sigma; -data.gain = gain; -data.maxval = maxval; + + +if (trainnumEdata); +if size(p1,2)>40000 + p2 = randperm(size(p1,2)); + p2=sort(p2(1:40000)); + size(p2,2) + SMALL.Problem.b=X(:,p1(p2)); +else + size(p1,2) + SMALL.Problem.b=X(:,p1); + +end + +% Forgetting factor for RLS-DLA algorithm, in this case we are using +% fixed value + +lambda=0.9998 + +% Use Recursive Least Squares +% to Learn overcomplete dictionary + +% Initialising Dictionary structure +% Setting Dictionary structure fields (toolbox, name, param, D and time) +% to zero values + +SMALL.DL(3)=SMALL_init_DL(); + +% Defining fields needed for dictionary learning + +SMALL.DL(3).toolbox = 'SMALL'; +SMALL.DL(3).name = 'SMALL_rlsdla'; +SMALL.DL(3).param=struct(... + 'Edata', Edata,... + 'initdict', SMALL.Problem.initdict,... + 'dictsize', SMALL.Problem.p,... + 'forgettingMode', 'FIX',... + 'forgettingFactor', lambda,... + 'show_dict', 1000); + + +SMALL.DL(3) = SMALL_learn(SMALL.Problem, SMALL.DL(3)); + +% Initialising solver structure +% Setting solver structure fields (toolbox, name, param, solution, +% reconstructed and time) to zero values + +SMALL.Problem.A = SMALL.DL(3).D; +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); + +SMALL.solver(3)=SMALL_init_solver; + +% Defining the parameters needed for image denoising + +SMALL.solver(3).toolbox='ompbox'; +SMALL.solver(3).name='omp2'; +SMALL.solver(3).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); + + +SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3)); + +SMALL.solver(3).reconstructed.psnr + + +% show results % + +SMALL_ImgDeNoiseResult(SMALL); + +results(noise_ind,im_num).psnr.ksvd=SMALL.solver(1).reconstructed.psnr; +results(noise_ind,im_num).psnr.odct=SMALL.solver(2).reconstructed.psnr; +results(noise_ind,im_num).psnr.rlsdla=SMALL.solver(3).reconstructed.psnr; +results(noise_ind,im_num).vmrse.ksvd=SMALL.solver(1).reconstructed.vmrse; +results(noise_ind,im_num).vmrse.odct=SMALL.solver(2).reconstructed.vmrse; +results(noise_ind,im_num).vmrse.rlsdla=SMALL.solver(3).reconstructed.vmrse; +results(noise_ind,im_num).ssim.ksvd=SMALL.solver(1).reconstructed.ssim; +results(noise_ind,im_num).ssim.odct=SMALL.solver(2).reconstructed.ssim; +results(noise_ind,im_num).ssim.rlsdla=SMALL.solver(3).reconstructed.ssim; + +results(noise_ind,im_num).time.ksvd=SMALL.solver(1).time+SMALL.DL(1).time; +results(noise_ind,im_num).time.rlsdla.time=SMALL.solver(3).time+SMALL.DL(3).time; +clear SMALL; +end +end +% save results.mat results diff -r b14209313ba4 -r f42aa8bcb82f examples/Automatic Music Transcription/SMALL_AMT_DL_test.m --- a/examples/Automatic Music Transcription/SMALL_AMT_DL_test.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_DL_test.m Wed Aug 31 12:02:19 2011 +0100 @@ -31,7 +31,7 @@ % Defining Automatic Transcription of Piano tune as Dictionary Learning % Problem -SMALL.Problem = generateAMT_Learning_Problem(); +SMALL.Problem = generateAMTProblem(); %% % Use KSVD Dictionary Learning Algorithm to Learn 88 notes (defined in @@ -67,7 +67,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) SMALL_midiGenerate(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) AMT_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -151,7 +151,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct=@(x) SMALL_midiGenerate(x, SMALL.Problem); +SMALL.Problem.reconstruct=@(x) AMT_reconstruct(x, SMALL.Problem); %% % Initialising solver structure diff -r b14209313ba4 -r f42aa8bcb82f examples/Automatic Music Transcription/SMALL_AMT_KSVD_Err_test.m --- a/examples/Automatic Music Transcription/SMALL_AMT_KSVD_Err_test.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_KSVD_Err_test.m Wed Aug 31 12:02:19 2011 +0100 @@ -33,7 +33,7 @@ % Defining Automatic Transcription of Piano tune as Dictionary Learning % Problem -SMALL.Problem = generateAMT_Learning_Problem(); +SMALL.Problem = generateAMTProblem(); TPmax=0; for i=1:5 %% @@ -76,7 +76,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(i).D; - SMALL.Problem.reconstruct = @(x) SMALL_midiGenerate(x, SMALL.Problem); + SMALL.Problem.reconstruct = @(x) AMT_reconstruct(x, SMALL.Problem); %% % Initialising solver structure diff -r b14209313ba4 -r f42aa8bcb82f examples/Automatic Music Transcription/SMALL_AMT_KSVD_Sparsity_test.m --- a/examples/Automatic Music Transcription/SMALL_AMT_KSVD_Sparsity_test.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_KSVD_Sparsity_test.m Wed Aug 31 12:02:19 2011 +0100 @@ -33,7 +33,7 @@ % Defining Automatic Transcription of Piano tune as Dictionary Learning % Problem -SMALL.Problem = generateAMT_Learning_Problem(); +SMALL.Problem = generateAMTProblem(); TPmax=0; @@ -73,7 +73,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(i).D; - SMALL.Problem.reconstruct = @(x) SMALL_midiGenerate(x, SMALL.Problem); + SMALL.Problem.reconstruct = @(x) AMT_reconstruct(x, SMALL.Problem); %% % Initialising solver structure diff -r b14209313ba4 -r f42aa8bcb82f examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m --- a/examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m Wed Aug 31 12:02:19 2011 +0100 @@ -33,7 +33,7 @@ % Defining Automatic Transcription of Piano tune as Dictionary Learning % Problem -SMALL.Problem = generateAMT_Learning_Problem(); +SMALL.Problem = generateAMTProblem(); TPmax=0; %% for i=1:10 @@ -77,7 +77,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(i).D; - SMALL.Problem.reconstruct=@(x) SMALL_midiGenerate(x, SMALL.Problem); + SMALL.Problem.reconstruct=@(x) AMT_reconstruct(x, SMALL.Problem); %% diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m Wed Aug 31 12:02:19 2011 +0100 @@ -99,7 +99,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -140,7 +140,7 @@ % Setting up reconstruction function SparseDict=0; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem, SparseDict); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem, SparseDict); % Initialising solver structure % Setting solver structure fields (toolbox, name, param, solution, @@ -217,7 +217,7 @@ % reconstructed and time) to zero values SMALL.Problem.A = SMALL.DL(3).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); SMALL.solver(3)=SMALL_init_solver; diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLAvsTwoStepMOD.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLAvsTwoStepMOD.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLAvsTwoStepMOD.m Wed Aug 31 12:02:19 2011 +0100 @@ -102,7 +102,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -183,7 +183,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses @@ -247,7 +247,7 @@ % reconstructed and time) to zero values SMALL.Problem.A = SMALL.DL(3).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); SMALL.solver(3)=SMALL_init_solver; diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m Wed Aug 31 12:02:19 2011 +0100 @@ -97,7 +97,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -175,7 +175,7 @@ % Setting up reconstruction function SparseDict=1; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem, SparseDict); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem, SparseDict); % Initialising solver structure % Setting solver structure fields (toolbox, name, param, solution, @@ -237,7 +237,7 @@ % Setting up reconstruction function -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Initialising solver structure % Setting solver structure fields (toolbox, name, param, solution, diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsTwoStepKSVD.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsTwoStepKSVD.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsTwoStepKSVD.m Wed Aug 31 12:02:19 2011 +0100 @@ -103,7 +103,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -182,7 +182,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m Wed Aug 31 12:02:19 2011 +0100 @@ -90,7 +90,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m Wed Aug 31 12:02:19 2011 +0100 @@ -100,7 +100,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; - SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); + SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -167,7 +167,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; - SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); + SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure diff -r b14209313ba4 -r f42aa8bcb82f examples/Image Denoising/SMALL_ImgDenoise_DL_test_TwoStep_KSVD_MOD_OLS_Mailhe.m --- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_TwoStep_KSVD_MOD_OLS_Mailhe.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_TwoStep_KSVD_MOD_OLS_Mailhe.m Wed Aug 31 12:02:19 2011 +0100 @@ -111,7 +111,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses @@ -170,7 +170,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses @@ -230,7 +230,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(3).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses @@ -290,7 +290,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(4).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses diff -r b14209313ba4 -r f42aa8bcb82f examples/MajorizationMinimization tests/SMALL_AMT_DL_test_KSVD_MM.m --- a/examples/MajorizationMinimization tests/SMALL_AMT_DL_test_KSVD_MM.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/MajorizationMinimization tests/SMALL_AMT_DL_test_KSVD_MM.m Wed Aug 31 12:02:19 2011 +0100 @@ -38,7 +38,7 @@ % Defining Automatic Transcription of Piano tune as Dictionary Learning % Problem -SMALL.Problem = generateAMT_Learning_Problem('',2048,0.75); +SMALL.Problem = generateAMTProblem('',2048,0.75); %% % Use KSVD Dictionary Learning Algorithm to Learn 88 notes (defined in @@ -74,7 +74,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) SMALL_midiGenerate(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) AMT_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -216,7 +216,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct=@(x) SMALL_midiGenerate(x, SMALL.Problem); +SMALL.Problem.reconstruct=@(x) AMT_reconstruct(x, SMALL.Problem); % Call SMALL_soolve to represent the signal in the given dictionary. diff -r b14209313ba4 -r f42aa8bcb82f examples/MajorizationMinimization tests/SMALL_AudioDenoise_DL_test_KSVDvsSPAMS.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/MajorizationMinimization tests/SMALL_AudioDenoise_DL_test_KSVDvsSPAMS.m Wed Aug 31 12:02:19 2011 +0100 @@ -0,0 +1,128 @@ +%% DICTIONARY LEARNING FOR AUDIO DENOISING +% This file contains an example of how SMALLbox can be used to test different +% dictionary learning techniques in Audio Denoising problem. +% It calls generateAudioDenoiseProblem that will let you to choose audio file, +% add noise and use noisy audio to generate training set for dictionary +% learning. +% +% +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2011 Ivan Damnjanovic. +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License as +% published by the Free Software Foundation; either version 2 of the +% License, or (at your option) any later version. See the file +% COPYING included with this distribution for more information. +% +%% + +clear; + +% Defining Audio Denoising Problem as Dictionary Learning +% Problem + +SMALL.Problem = generateAudioDenoiseProblem('male01_8kHz',0.1,512,1/128,'','','',4); + +%% +% Initialising solver structure +% Setting solver structure fields (toolbox, name, param, solution, +% reconstructed and time) to zero values + +SMALL.solver(1)=SMALL_init_solver('MMbox', 'mm1', '', 1); + +% Defining the parameters needed for image denoising + +SMALL.solver(1).param=struct(... + 'lambda', 0.2,... + 'epsilon', 3*10^-4,... + 'iternum',10); + +% Initialising Dictionary structure +% Setting Dictionary structure fields (toolbox, name, param, D and time) +% to zero values + +SMALL.DL(1)=SMALL_init_DL('MMbox', 'MM_cn', '', 1); + + +% Defining the parameters for MOD +% In this example we are learning 256 atoms in 20 iterations, so that +% every patch in the training set can be represented with target error in +% L2-norm (EData) +% Type help ksvd in MATLAB prompt for more options. + + +SMALL.DL(1).param=struct(... + 'solver', SMALL.solver(1),... + 'initdict', SMALL.Problem.initdict,... + 'dictsize', SMALL.Problem.p,... + 'iternum', 20,... + 'iterDictUpdate', 10,... + 'epsDictUpdate', 10^-7,... + 'cvset',0,... + 'show_dict', 0); + +% Learn the dictionary + +SMALL.DL(1) = SMALL_learn(SMALL.Problem, SMALL.DL(1)); + +% Set SMALL.Problem.A dictionary +% (backward compatiblity with SPARCO: solver structure communicate +% only with Problem structure, ie no direct communication between DL and +% solver structures) + +SMALL.Problem.A = SMALL.DL(1).D; +SMALL.Problem.reconstruct = @(x) AudioDenoise_reconstruct(x, SMALL.Problem); +% Denoising the image - find the sparse solution in the learned +% dictionary for all patches in the image and the end it uses +% reconstruction function to reconstruct the patches and put them into a +% denoised image + +SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1)); + +%% +%% +% % sparse coding using SPAMS online dictionary learning +% + +SMALL.DL(2)=SMALL_init_DL(); +SMALL.DL(2).toolbox = 'SPAMS'; +SMALL.DL(2).name = 'mexTrainDL'; +SMALL.DL(2).param=struct('D', SMALL.Problem.initdict, 'K', SMALL.Problem.p, 'lambda', 0.2, 'iter', 200, 'mode', 3, 'modeD', 0); + + +SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2)); + +% Defining Reconstruction function + +SMALL.Problem.A = SMALL.DL(2).D; + + +%% +% Initialising solver structure +% Setting toolbox, name, param, solution, reconstructed and time to zero values + +SMALL.solver(2)=SMALL_init_solver; + +% Defining the parameters needed for sparse representation + +SMALL.solver(2).toolbox='ompbox'; +SMALL.solver(2).name='omp2'; +SMALL.solver(2).param=struct(... + 'epsilon',0.2,... + 'maxatoms', 128); +% Represent Training set in the learned dictionary + +SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2)); + + + + +%% +% Plot results and save midi files + +% show results % + + +SMALL_AudioDeNoiseResult(SMALL); + \ No newline at end of file diff -r b14209313ba4 -r f42aa8bcb82f examples/MajorizationMinimization tests/SMALL_ImgDenoise_DL_test_KSVDvsMajorizationMinimization.m --- a/examples/MajorizationMinimization tests/SMALL_ImgDenoise_DL_test_KSVDvsMajorizationMinimization.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/MajorizationMinimization tests/SMALL_ImgDenoise_DL_test_KSVDvsMajorizationMinimization.m Wed Aug 31 12:02:19 2011 +0100 @@ -103,7 +103,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -184,7 +184,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; -SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); +SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); % Denoising the image - find the sparse solution in the learned % dictionary for all patches in the image and the end it uses diff -r b14209313ba4 -r f42aa8bcb82f examples/Pierre Villars/Pierre_Villars_Example.m --- a/examples/Pierre Villars/Pierre_Villars_Example.m Mon Aug 22 11:46:35 2011 +0100 +++ b/examples/Pierre Villars/Pierre_Villars_Example.m Wed Aug 31 12:02:19 2011 +0100 @@ -23,7 +23,7 @@ % Defining the Problem structure -SMALL.Problem = generatePierre_Problem(); +SMALL.Problem = generatePierreProblem(); % Show original image and image that is used as a dictionary figure('Name', 'Original and Dictionary Image'); diff -r b14209313ba4 -r f42aa8bcb82f util/SMALL_AudioDeNoiseResult.m --- a/util/SMALL_AudioDeNoiseResult.m Mon Aug 22 11:46:35 2011 +0100 +++ b/util/SMALL_AudioDeNoiseResult.m Wed Aug 31 12:02:19 2011 +0100 @@ -2,7 +2,7 @@ %% Plots the results of Audio denoising experiment - underconstruction % Centre for Digital Music, Queen Mary, University of London. -% This file copyright 2009 Ivan Damnjanovic. +% This file copyright 2011 Ivan Damnjanovic. % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -13,7 +13,7 @@ fMain=figure('Name', sprintf('File %s (training set size- %d, sigma - %d)',SMALL.Problem.name, SMALL.Problem.n, SMALL.Problem.sigma)); m=size(SMALL.solver,2); -maxval=SMALL.Problem.maxval; +maxval=max(SMALL.Problem.Original); au=SMALL.Problem.Original; aunoise=SMALL.Problem.Noisy; @@ -25,7 +25,7 @@ for i=1:m params=SMALL.solver(i).param; - sWav=subplot(2, m, m+i, 'Parent', fMain); plot(SMALL.solver(i).reconstructed.Image/maxval, 'Parent', sWav); + sWav=subplot(2, m, m+i, 'Parent', fMain); plot(SMALL.solver(i).reconstructed.audio/maxval, 'Parent', sWav); title(sprintf('%s Denoised audio, PSNR: %.2fdB', SMALL.DL(i).name, SMALL.solver(i).reconstructed.psnr),'Parent', sWav ); if strcmpi(SMALL.DL(i).name,'ksvds') D = kron(SMALL.Problem.basedict{2},SMALL.Problem.basedict{1})*SMALL.DL(i).D; diff -r b14209313ba4 -r f42aa8bcb82f util/SMALL_solve.m --- a/util/SMALL_solve.m Mon Aug 22 11:46:35 2011 +0100 +++ b/util/SMALL_solve.m Wed Aug 31 12:02:19 2011 +0100 @@ -1,5 +1,5 @@ function solver = SMALL_solve(Problem, solver) -%% SMALL sparse solver +%% SMALL sparse solver caller function % % Function gets as input SMALL structure that contains SPARCO problem to % be solved, name of the toolbox and solver, and parameters file for @@ -88,7 +88,7 @@ [y, numiter, time, y_path] = wrapper_ALPS_toolbox(b, A, solver.param); elseif (strcmpi(solver.toolbox, 'MMbox')) if ~isa(Problem.A,'float') - % ALPS does not accept implicit dictionary definition + % MMbox does not accept implicit dictionary definition A = opToMatrix(Problem.A, 1); end