Mercurial > hg > smallbox
changeset 107:dab78a3598b6
changes to comments for couple of scripts
author | Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk> |
---|---|
date | Wed, 18 May 2011 11:50:12 +0100 (2011-05-18) |
parents | fd1c32cda22c |
children | b14e1f6ee4be |
files | SMALLboxSetup.m examples/Automatic Music Transcription/SMALL_AMT_DL_test.m examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m examples/Pierre Villars/Pierre_Villars_Example.m util/AMT_analysis.m |
diffstat | 9 files changed, 310 insertions(+), 247 deletions(-) [+] |
line wrap: on
line diff
--- a/SMALLboxSetup.m Tue Apr 05 17:03:26 2011 +0100 +++ b/SMALLboxSetup.m Wed May 18 11:50:12 2011 +0100 @@ -1,5 +1,13 @@ function SMALLboxSetup(varargin) %%% SMALLboxSetup +% +% Will automatically download and install existing toolboxes +% on sparse representations and dictionary learning +% +% For this function an internet connection is required. +% +% SMALLbox initialisation + % % Centre for Digital Music, Queen Mary, University of London. % This file copyright 2009 Ivan Damnjanovic, Matthew Davies. @@ -10,13 +18,6 @@ % License, or (at your option) any later version. See the file % COPYING included with this distribution for more information. % -% -% Will automatically download and install existing toolboxes -% on sparse representations and dictionary learning -% -% For this function an internet connection is required. -% -% SMALLbox initialisation %% clc;
--- a/examples/Automatic Music Transcription/SMALL_AMT_DL_test.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_DL_test.m Wed May 18 11:50:12 2011 +0100 @@ -1,13 +1,4 @@ %% DICTIONARY LEARNING FOR AUTOMATIC MUSIC TRANSCRIPTION EXAMPLE 1 -% -% Centre for Digital Music, Queen Mary, University of London. -% This file copyright 2010 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. % % This file contains an example of how SMALLbox can be used to test diferent % dictionary learning techniques in Automatic Music Transcription problem. @@ -18,7 +9,16 @@ % The function will generarte the Problem structure that is used to learn % Problem.p notes spectrograms from training set Problem.b using % dictionary learning technique defined in DL structure. + % +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2010 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; @@ -45,13 +45,13 @@ SMALL.DL(1).name = 'ksvd'; % Defining the parameters for KSVD % In this example we are learning 88 atoms in 100 iterations, so that -% every frame in the training set can be represented with maximum 3 +% every frame in the training set can be represented with maximum Tdata % dictionary elements. Type help ksvd in MATLAB prompt for more options. SMALL.DL(1).param=struct(... - 'Tdata', 10,... + 'Tdata', 3,... 'dictsize', SMALL.Problem.p,... - 'iternum', 100); + 'iternum', 50); % Learn the dictionary @@ -110,82 +110,82 @@ %% -% % Here we solve the same problem using non-negative sparse coding with -% % SPAMS online dictionary learning (Julien Mairal 2009) -% % -% -% % Initialising Dictionary structure -% % Setting Dictionary structure fields (toolbox, name, param, D and time) -% % to zero values -% -% SMALL.DL(2)=SMALL_init_DL(); -% -% -% % Defining fields needed for dictionary learning -% -% SMALL.DL(2).toolbox = 'SPAMS'; -% SMALL.DL(2).name = 'mexTrainDL'; -% -% % Type 'help mexTrainDL in MATLAB prompt for explanation of parameters. -% -% SMALL.DL(2).param=struct(... -% 'K', SMALL.Problem.p,... -% 'lambda', 3,... -% 'iter', 300,... -% 'posAlpha', 1,... -% 'posD', 1,... -% 'whiten', 0,... -% 'mode', 2); -% -% % Learn the dictionary -% -% SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2)); -% -% % Set SMALL.Problem.A dictionary and reconstruction function -% % (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(2).D; -% SMALL.Problem.reconstruct=@(x) SMALL_midiGenerate(x, SMALL.Problem); -% -% %% -% % Initialising solver structure -% % Setting solver structure fields (toolbox, name, param, solution, -% % reconstructed and time) to zero values -% % As an example, SPAMS (Julien Mairal 2009) implementation of LARS -% % algorithm is used for representation of training set in the learned -% % dictionary. -% -% SMALL.solver(2)=SMALL_init_solver; -% -% % Defining the parameters needed for sparse representation -% -% SMALL.solver(2).toolbox='SPAMS'; -% SMALL.solver(2).name='mexLasso'; -% -% % Here we use mexLasso mode=2, with lambda=3, lambda2=0 and positivity -% % constrain (type 'help mexLasso' for more information about modes): -% % -% % min_{alpha_i} (1/2)||x_i-Dalpha_i||_2^2 + lambda||alpha_i||_1 + (1/2)lambda2||alpha_i||_2^2 -% -% SMALL.solver(2).param=struct('lambda', 3, 'pos', 1, 'mode', 2); -% -% % Call SMALL_soolve to represent the signal in the given dictionary. -% % As a final command SMALL_solve will call above defined reconstruction -% % function to reconstruct the training set (Problem.b) in the learned -% % dictionary (Problem.A) -% -% SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2)); -% -% %% -% % Analysis of the result of automatic music transcription. If groundtruth -% % exists, we can compare transcribed notes and original and get usual -% % True Positives, False Positives and False Negatives measures. -% -% if ~isempty(SMALL.Problem.notesOriginal) -% AMT_res(2) = AMT_analysis(SMALL.Problem, SMALL.solver(2)); -% end +% Here we solve the same problem using non-negative sparse coding with +% SPAMS online dictionary learning (Julien Mairal 2009) +% + +% Initialising Dictionary structure +% Setting Dictionary structure fields (toolbox, name, param, D and time) +% to zero values + +SMALL.DL(2)=SMALL_init_DL(); + + +% Defining fields needed for dictionary learning + +SMALL.DL(2).toolbox = 'SPAMS'; +SMALL.DL(2).name = 'mexTrainDL'; + +% Type 'help mexTrainDL in MATLAB prompt for explanation of parameters. + +SMALL.DL(2).param=struct(... + 'K', SMALL.Problem.p,... + 'lambda', 3,... + 'iter', 300,... + 'posAlpha', 1,... + 'posD', 1,... + 'whiten', 0,... + 'mode', 2); + +% Learn the dictionary + +SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2)); + +% Set SMALL.Problem.A dictionary and reconstruction function +% (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(2).D; +SMALL.Problem.reconstruct=@(x) SMALL_midiGenerate(x, SMALL.Problem); + +%% +% Initialising solver structure +% Setting solver structure fields (toolbox, name, param, solution, +% reconstructed and time) to zero values +% As an example, SPAMS (Julien Mairal 2009) implementation of LARS +% algorithm is used for representation of training set in the learned +% dictionary. + +SMALL.solver(2)=SMALL_init_solver; + +% Defining the parameters needed for sparse representation + +SMALL.solver(2).toolbox='SPAMS'; +SMALL.solver(2).name='mexLasso'; + +% Here we use mexLasso mode=2, with lambda=3, lambda2=0 and positivity +% constrain (type 'help mexLasso' for more information about modes): +% +% min_{alpha_i} (1/2)||x_i-Dalpha_i||_2^2 + lambda||alpha_i||_1 + (1/2)lambda2||alpha_i||_2^2 + +SMALL.solver(2).param=struct('lambda', 3, 'pos', 1, 'mode', 2); + +% Call SMALL_soolve to represent the signal in the given dictionary. +% As a final command SMALL_solve will call above defined reconstruction +% function to reconstruct the training set (Problem.b) in the learned +% dictionary (Problem.A) + +SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2)); + +%% +% Analysis of the result of automatic music transcription. If groundtruth +% exists, we can compare transcribed notes and original and get usual +% True Positives, False Positives and False Negatives measures. + +if ~isempty(SMALL.Problem.notesOriginal) + AMT_res(2) = AMT_analysis(SMALL.Problem, SMALL.solver(2)); +end %% % Plot results and save midi files
--- a/examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Automatic Music Transcription/SMALL_AMT_SPAMS_test.m Wed May 18 11:50:12 2011 +0100 @@ -1,13 +1,4 @@ %% DICTIONARY LEARNING FOR AUTOMATIC MUSIC TRANSCRIPTION EXAMPLE 1 -% -% Centre for Digital Music, Queen Mary, University of London. -% This file copyright 2010 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. % % This file contains an example of how SMALLbox can be used to test diferent % dictionary learning techniques in Automatic Music Transcription problem. @@ -18,6 +9,16 @@ % The function will generarte the Problem structure that is used to learn % Problem.p notes spectrograms from training set Problem.b using % dictionary learning technique defined in DL structure. + +% +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2010 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. % %%
--- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m Wed May 18 11:50:12 2011 +0100 @@ -250,7 +250,7 @@ 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; +clear SMALL; end end -save results.mat results +% save results.mat results
--- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSPAMS.m Wed May 18 11:50:12 2011 +0100 @@ -1,13 +1,5 @@ %% DICTIONARY LEARNING FOR IMAGE DENOISING -% -% 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. + % % This file contains an example of how SMALLbox can be used to test different % dictionary learning techniques in Image Denoising problem. @@ -25,6 +17,16 @@ % Dictionary Learning for Sparse Coding. International % Conference on Machine Learning,Montreal, Canada, 2009 % + +% +% 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. % %% @@ -73,6 +75,8 @@ % Type help ksvd in MATLAB prompt for more options. Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain; +maxatoms = floor(prod(SMALL.Problem.blocksize)/2); + SMALL.DL(1).param=struct(... 'Edata', Edata,... 'initdict', SMALL.Problem.initdict,... @@ -90,7 +94,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; - +SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -102,12 +106,21 @@ % Defining the parameters needed for image denoising SMALL.solver(1).toolbox='ompbox'; -SMALL.solver(1).name='ompdenoise'; +SMALL.solver(1).name='omp2'; +SMALL.solver(1).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); -% Denoising the image - SMALL_denoise function is similar to SMALL_solve, -% but backward compatible with KSVD definition of denoising +% 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_denoise(SMALL.Problem, SMALL.solver(1)); +SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1)); + +% Show PSNR after reconstruction + +SMALL.solver(1).reconstructed.psnr %% % Use KSVDS Dictionary Learning Algorithm to denoise image @@ -156,7 +169,11 @@ SMALL.Problem.basedict{1} = SMALL.DL(2).param.basedict{1}; SMALL.Problem.basedict{2} = SMALL.DL(2).param.basedict{2}; -%% +% Setting up reconstruction function + +SparseDict=1; +SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem, SparseDict); + % Initialising solver structure % Setting solver structure fields (toolbox, name, param, solution, % reconstructed and time) to zero values @@ -166,69 +183,79 @@ % Defining the parameters needed for image denoising SMALL.solver(2).toolbox='ompsbox'; -SMALL.solver(2).name='ompsdenoise'; +SMALL.solver(2).name='omps2'; +SMALL.solver(2).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); -% Denoising the image - SMALL_denoise function is similar to SMALL_solve, -% but backward compatible with KSVD definition of denoising -% Pay attention that since implicit base dictionary is used, denoising -% can be much faster then using explicit dictionary in KSVD example. +% 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(2)=SMALL_denoise(SMALL.Problem, SMALL.solver(2)); +SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2)); -% %% -% % Use SPAMS Online Dictionary Learning Algorithm -% % to Learn overcomplete dictionary (Julien Mairal 2009) -% % (If you have not installed SPAMS please comment the following two cells) -% -% % 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 = 'SPAMS'; -% SMALL.DL(3).name = 'mexTrainDL'; -% -% % Type 'help mexTrainDL in MATLAB prompt for explanation of parameters. -% -% SMALL.DL(3).param=struct(... -% 'D', SMALL.Problem.initdict,... -% 'K', SMALL.Problem.p,... -% 'lambda', 2,... -% 'iter', 200,... -% 'mode', 3, ... -% 'modeD', 0); -% -% % Learn the dictionary -% -% SMALL.DL(3) = SMALL_learn(SMALL.Problem, SMALL.DL(3)); -% -% % 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(3).D; -% -% -% %% -% % Initialising solver structure -% % Setting solver structure fields (toolbox, name, param, solution, -% % reconstructed and time) to zero values -% -% SMALL.solver(3)=SMALL_init_solver; -% -% % Defining the parameters needed for denoising -% -% SMALL.solver(3).toolbox='ompbox'; -% SMALL.solver(3).name='ompdenoise'; -% -% % Denoising the image - SMALL_denoise function is similar to SMALL_solve, -% % but backward compatible with KSVD definition of denoising -% -% SMALL.solver(3)=SMALL_denoise(SMALL.Problem, SMALL.solver(3)); +%% +% Use SPAMS Online Dictionary Learning Algorithm +% to Learn overcomplete dictionary (Julien Mairal 2009) +% (If you have not installed SPAMS please comment the following two cells) + +% 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 = 'SPAMS'; +SMALL.DL(3).name = 'mexTrainDL'; + +% Type 'help mexTrainDL in MATLAB prompt for explanation of parameters. + +SMALL.DL(3).param=struct(... + 'D', SMALL.Problem.initdict,... + 'K', SMALL.Problem.p,... + 'lambda', 2,... + 'iter', 200,... + 'mode', 3, ... + 'modeD', 0); + +% Learn the dictionary + +SMALL.DL(3) = SMALL_learn(SMALL.Problem, SMALL.DL(3)); + +% 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(3).D; + +% Setting up reconstruction function + +SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); + +% Initialising solver structure +% Setting solver structure fields (toolbox, name, param, solution, +% reconstructed and time) to zero values + +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); + +% 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(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3)); %% % Plot results and save midi files
--- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_SPAMS_lambda.m Wed May 18 11:50:12 2011 +0100 @@ -1,5 +1,14 @@ %% DICTIONARY LEARNING FOR IMAGE DENOISING % +% +% This file contains an example of how SMALLbox can be used to test different +% dictionary learning techniques in Image Denoising problem. +% This example can be used to test SPAMS for different values of +% parameter lambda. In no way it represents extensive testing of image +% denoising. It should only give an idea how SMALL structure can be used +% for testing. + +% % Centre for Digital Music, Queen Mary, University of London. % This file copyright 2010 Ivan Damnjanovic. % @@ -8,14 +17,6 @@ % 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. -% -% This file contains an example of how SMALLbox can be used to test different -% dictionary learning techniques in Image Denoising problem. -% This example can be used to test SPAMS for different values of -% parameter lambda. In no way it represents extensive testing of image -% denoising. It should only give an idea how SMALL structure can be used -% for testing. -% %% clear all; @@ -86,25 +87,31 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; - - - %% - % Initialising solver structure - % Setting solver structure fields (toolbox, name, param, solution, - % reconstructed and time) to zero values - - SMALL.solver(1)=SMALL_init_solver; - - % Defining the parameters needed for sparse representation - - SMALL.solver(1).toolbox='ompbox'; - SMALL.solver(1).name='ompdenoise'; - - % Denoising the image - SMALL_denoise function is similar to SMALL_solve, - % but backward compatible with KSVD definition of denoising - - SMALL.solver(1)=SMALL_denoise(SMALL.Problem, SMALL.solver(1)); - +SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); + +%% +% Initialising solver structure +% Setting solver structure fields (toolbox, name, param, solution, +% reconstructed and time) to zero values + +SMALL.solver(1)=SMALL_init_solver; + +% Defining the parameters needed for image denoising +Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain; +maxatoms = floor(prod(SMALL.Problem.blocksize)/2); + +SMALL.solver(1).toolbox='ompbox'; +SMALL.solver(1).name='omp2'; +SMALL.solver(1).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); + +% 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)); %% show results %% % This will show denoised image and dictionary for all lambdas. If you
--- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_Training_size.m Wed May 18 11:50:12 2011 +0100 @@ -1,14 +1,6 @@ %% DICTIONARY LEARNING FOR IMAGE DENOISING % -% Centre for Digital Music, Queen Mary, University of London. -% This file copyright 20100 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. -% + % This file contains an example of how SMALLbox can be used to test different % dictionary learning techniques in Image Denoising problem. % It calls generateImageDenoiseProblem that will let you to choose image, @@ -25,8 +17,16 @@ % - SPAMS - J. Mairal, F. Bach, J. Ponce and G. Sapiro. Online % Dictionary Learning for Sparse Coding. International % Conference on Machine Learning,Montreal, Canada, 2009 + % +% Centre for Digital Music, Queen Mary, University of London. +% This file copyright 2010 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 all; @@ -77,6 +77,8 @@ % Type help ksvd in MATLAB prompt for more options. Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain; + maxatoms = floor(prod(SMALL.Problem.blocksize)/2); + SMALL.DL(1).param=struct(... 'Edata', Edata,... 'initdict', SMALL.Problem.initdict,... @@ -94,7 +96,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(1).D; - + SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -107,12 +109,23 @@ % Defining the parameters needed for denoising SMALL.solver(1).toolbox='ompbox'; - SMALL.solver(1).name='ompdenoise'; + SMALL.solver(1).name='omp2'; - % Denoising the image - SMALL_denoise function is similar to SMALL_solve, - % but backward compatible with KSVD definition of denoising - - SMALL.solver(1)=SMALL_denoise(SMALL.Problem, SMALL.solver(1)); + SMALL.solver(1).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); + + % 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)); + + % Show PSNR after reconstruction + + SMALL.solver(1).reconstructed.psnr + %% % Use SPAMS Online Dictionary Learning Algorithm @@ -150,7 +163,7 @@ % solver structures) SMALL.Problem.A = SMALL.DL(2).D; - + SMALL.Problem.reconstruct = @(x) ImgDenoise_reconstruct(x, SMALL.Problem); %% % Initialising solver structure @@ -162,12 +175,18 @@ % Defining the parameters needed for denoising SMALL.solver(2).toolbox='ompbox'; - SMALL.solver(2).name='ompdenoise'; - - % Denoising the image - SMALL_denoise function is similar to SMALL_solve, - % but backward compatible with KSVD definition of denoising - - SMALL.solver(2)=SMALL_denoise(SMALL.Problem, SMALL.solver(2)); + SMALL.solver(2).name='omp2'; + SMALL.solver(2).param=struct(... + 'epsilon',Edata,... + 'maxatoms', maxatoms); + + % 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(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2)); +
--- a/examples/Pierre Villars/Pierre_Villars_Example.m Tue Apr 05 17:03:26 2011 +0100 +++ b/examples/Pierre Villars/Pierre_Villars_Example.m Wed May 18 11:50:12 2011 +0100 @@ -1,4 +1,12 @@ %% Pierre Villars Example +% +% This example is based on the experiment suggested by Professor Pierre +% Vandergheynst on the SMALL meeting in Villars. +% The idea behind is to use patches from source image as a dictionary in +% which we represent target image using matching pursuit algorithm. +% Calling Pierre_Problem function to get src image to be used as dictionary +% and target image to be represented using MP with 3 patches from source image + % % Centre for Digital Music, Queen Mary, University of London. % This file copyright 2010 Ivan Damnjanovic. @@ -8,13 +16,6 @@ % 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. -% -% This example is based on the experiment suggested by Professor Pierre -% Vandergheynst on the SMALL meeting in Villars. -% The idea behind is to use patches from source image as a dictionary in -% which we represent target image using matching pursuit algorithm. -% Calling Pierre_Problem function to get src image to be used as dictionary -% and target image to be represented using MP with 3 patches from source image % %%
--- a/util/AMT_analysis.m Tue Apr 05 17:03:26 2011 +0100 +++ b/util/AMT_analysis.m Wed May 18 11:50:12 2011 +0100 @@ -1,14 +1,5 @@ function AMT_res = AMT_analysis(Problem, solver) %%% Automatic Music Transcription results analysis -% -% 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. % % If wav file that is transcribed is generated from midi file (i.e. if % groundtruth exists) transcription is comapred to the original notes and @@ -22,6 +13,17 @@ % - FN - number of false negatives % - FP - number of false positives +% +% 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. +%% + timeOr=Problem.notesOriginal(:,5); noteOr=Problem.notesOriginal(:,3); timeTr=solver.reconstructed.notes(:,5); @@ -48,7 +50,12 @@ end AMT_res.tp_notes = [Problem.notesOriginal(Hits(:,1),[3 5]) solver.reconstructed.notes(Hits(:,2),[3 5])]; -AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])]; +if ~isempty(OE) + AMT_res.oe_notes = [Problem.notesOriginal(OE(:,1),[3 5]) solver.reconstructed.notes(OE(:,2),[3 5])]; +end +if isempty(OE) + OE=[0 0]; +end AMT_res.fn_notes_wo_oe = Problem.notesOriginal(setdiff([1:n],union(Hits(:,1),OE(:,1))),[3 5]); AMT_res.fp_notes_wo_oe = solver.reconstructed.notes(setdiff([1:m],union(Hits(:,2),OE(:,2))),[3 5]); AMT_res.TP=size(Hits,1);