changeset 246:cef4500b936f ver_2.1

Merge
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 31 Oct 2012 12:10:13 +0000
parents 96d17e5dc5d3 (diff) 5c8bcdadb380 (current diff)
children ecce33192fcc
files SMALLboxSetup.m
diffstat 10 files changed, 527 insertions(+), 509 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Sep 04 11:00:36 2012 +0100
+++ b/.hgtags	Wed Oct 31 12:10:13 2012 +0000
@@ -5,3 +5,10 @@
 19e0af5709140e163faaf9d8cf4b83a664be1edc release_1.5
 30872eb3d1606b89f8d071cfdb7cddb874fab8fd release_1.51
 4205744092e6a16951e48acef27fb41e32851758 release_1.9
+15fd4c5be71a70d812fa664817eeeb0954694978 ver_2.0_alpha1
+15fd4c5be71a70d812fa664817eeeb0954694978 ver_2.0_alpha1
+c96880c0c47cf2a17fbd11dacc9aaeaac8ff4ec3 ver_2.0_alpha1
+c96880c0c47cf2a17fbd11dacc9aaeaac8ff4ec3 ver_2.0_alpha1
+5f4e47b78f2b857208951b7570d2d3c5041603ee ver_2.0_alpha1
+71128ec3e532181c002bcbc16b31414f2ec0443e ver_2.0_beta
+423de9f24d98de2041f10adba30c36629fcf0c89 ver_2.0
--- a/README.txt	Tue Sep 04 11:00:36 2012 +0100
+++ b/README.txt	Wed Oct 31 12:10:13 2012 +0000
@@ -1,17 +1,16 @@
 
-SMALLbox Version 1.0 beta
+SMALLbox Version 2.0
 
-11th May, 2010
+25th May, 2012
 
-Version 1.0 beta of SMALLbox is the release candidate that is distributed 
+Version 2.0 of SMALLbox is the release candidate that is distributed 
 for testing and bug fixing purposes. Please send all bugs, requests and suggestions to:
 
-ivan.damnjanovic@elec.qmul.ac.uk
-
+luis.figueira@soundsoftware.ac.uk
 
 ---------------------------------------------------------------------------
 
-Copyright (2010): 	Ivan Damnjanovic, Matthew Davies
+Copyright (2012): 	Luis Figueira, Ivan Damnjanovic, Matthew Davies
 			Centre for Digital Music, 
 			Queen Mary University of London
 
@@ -91,9 +90,7 @@
 http://small-project.eu
 
 
-Contacts: ivan.damnjanovic@elec.qmul.ac.uk
-          matthew.davies@elec.qmul.ac.uk
-
+Contact: luis.figueira@soundsoftware.ac.uk
 
 This code is in experimental stage; any comments or bug reports are 
 very welcome. More information about using SMALLbox will be includied in release version 
--- a/SMALLboxSetup.m	Tue Sep 04 11:00:36 2012 +0100
+++ b/SMALLboxSetup.m	Wed Oct 31 12:10:13 2012 +0000
@@ -501,7 +501,7 @@
     SMALL_solver_test;
   case{'2'}
     fprintf('\n Running SMALL Image Denoise problem');
-    SMALL_ImgDenoise_DL_test_KSVDvsSPAMS;
+    SMALL_ImgDenoise_DL_test_KSVDvsRLSDLAvsTwoStepMOD.m;
   otherwise
     return;
   end
--- a/To Do list.m	Tue Sep 04 11:00:36 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-CardiacMRI:
-- Last thing I was dealing with was temporal fft operator that I have put in opFFTxd.m in util directory.
-- Problem setup is now kind of realistic:
-    - user choose upload cardiac images from dataset
-    - he can shose the slice number (1-10 - default is 5)
-    - sigma level (0.05 by default)
-    - undersampling factor (fold  default is 6)
-    - n image size (256 by default)
-    - read 3d matrix of n*n cardiac images in szt time points
-    - adds noise sigma*var(signal)
-    - do 2d circular fft per image and take random lines as specified by mask
-    - mask is made to sample n*szt/fold lines in phase encode and time dimensions
-    - play movies of original, undersampled cardiac images and mask
-    
-SMALLboxSetup.m - Installation script:
-
-- Add make call for DL/RLS_DLA/private and Problems/private (still need to 
-    shall these be private directories as in KSVD. Files inside are common
-    common routines that are used all around, so it makes sense to put them
-    in util directory)
-  SOLVED: A copy of "ksvd/private" is put into "util/ksvd utils" and istallation
-  script will run make command in the directory to compile mex files
-- 
\ No newline at end of file
--- a/bugs.m	Tue Sep 04 11:00:36 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-% MDP: File "COPYING" is not included in the distribution?
-
-% I encountered an error while running SMALL_solver_test_Audio :
-
-%??? Error using ==>
-%problems\private\completeOps>@(x)reshape(data.B(x,1),data.signalSize)
-%Too many input arguments.
-%Error in ==> SMALL_playAudio at 17
-%SMALL.solver.reconstructed  = SMALL.Problem.reconstruct(SMALL.solver.solution);
-%Error in ==> SMALL_solver_test_Audio at 96
-%SMALL_playAudio(SMALL);
- 
-
-% version of Matlab used: 7.9.0.529  - 64 bits
-
-
-
-Bugs by Raja Giryes:
-Using the tollbox on windows with Matlab R2010b:
-bug1:
-running SMALL_solver_test_Audio.m 
-I get:
-Starting solver SMALL_cgp... 
-Solver SMALL_cgp finished task in 251.208410 seconds (cpu time). 
-Solver SMALL_cgp finished task in 159.905633 seconds (tic-toc time). 
-
-Starting solver SolveBP... 
-??? Error using ==> eval
-Undefined function or method 'SolveBP' for input arguments of type
-'function_handle'.
-
-Error in ==> SMALL_solve at 46
-    y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']);
-
-Error in ==> SMALL_solver_test_Audio at 93
-SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
-
-running SMALL_solver_test.m
-I get:
-Starting solver SMALL_cgp... 
-Solver SMALL_cgp finished task in 2.839218 seconds (cpu time). 
-Solver SMALL_cgp finished task in 2.821443 seconds (tic-toc time). 
-
-Starting solver SolveOMP... 
-??? Error using ==> eval
-Undefined function or method 'SolveOMP' for input arguments of type
-'function_handle'.
-
-Error in ==> SMALL_solve at 46
-    y = eval([solver.name,'(SparseLab_A, b, n,',solver.param,');']);
-
-Error in ==> SMALL_solver_test at 113
-SMALL.solver(i)=SMALL_solve(SMALL.Problem, SMALL.solver(i));
-
-
-Bug report from Mehrdad Yaghoobi:
-1. The rice mdwt crashed on my matlab session runing on linux 64!!!
-2. problem with hg merge using EasyMercurial.
-
-
-
-
-% MDP: Files "my_dummy_solver.m" etc should include the boiler plate function
-% header etc.
-
-
-
-
-%%%%%%%%%%%%%%%%%
-% bug by Valentin
-%%%%%%%%%%%%%%%%%
-% In SMALLboxSetup.m
-% On Windows XP, 32 bits, Matlab R2010a
-% 
-% > SMALLboxSetup
-% ...
-% Compiling the Rice Wavelet Toolbox MEX interfaces...Error mdwt.c: 39  undeclared identifier `intptr_t' 
-% Warning mdwt.c: 39  Statement has no effect 
-% Error mdwt.c: 39  syntax error; found `m' expecting `;' 
-% Error mdwt.c: 39  undeclared identifier `m' 
-% Error mdwt.c: 39  undeclared identifier `n' 
-% Error mdwt.c: 39  undeclared identifier `h_col' 
-% Error mdwt.c: 39  undeclared identifier `h_row' 
-% Error mdwt.c: 39  undeclared identifier `lh' 
-% Error mdwt.c: 39  undeclared identifier `L' 
-% Error mdwt.c: 39  undeclared identifier `i' 
-% Error mdwt.c: 39  undeclared identifier `po2' 
-% Error mdwt.c: 39  undeclared identifier `j' 
-% Warning mdwt.c: 39  Statement has no effect 
-% Error mdwt.c: 40  illegal statement termination 
-% Error mdwt.c: 40  skipping `double' 
-% Error mdwt.c: 40  undeclared identifier `mtest' 
-% Error mdwt.c: 40  undeclared identifier `ntest' 
-% Warning mdwt.c: 40  Statement has no effect 
-% Error mdwt.c: 62  operands of * have illegal types `int' and `pointer to double' 
-% Warning mdwt.c: 39   possible usage of po2 before definition 
-% Warning mdwt.c: 39   possible usage of intptr_t before definition 
-% Warning mdwt.c: 38  local `pointer to double Lf' is not referenced 
-% Error mdwt.c: 106  missing parameter type 
-% Error mdwt.c: 106  syntax error; found `m' expecting `)' 
-% Error mdwt.c: 106  skipping `m' `,' `intptr_t' `n' `,' 
-% Error mdwt.c: 106  syntax error; found `double' expecting `{' 
-% Error mdwt.c: 106  too many errors 
-%  
-%   C:\PROGRA~1\MATLAB\R2010A\BIN\MEX.PL: Error: Compile of 'mdwt.c' failed. 
-%  
-% Warning: Could not compile Rice Wavelet Toolbox MEX interfaces.\n 
-% > In SMALLboxSetup at 365
-% 
-%  ******************************************************************
-% 
-%  Initialising SMALLbox Examples Setup
-%  ******************************************************************
-% 
-%  SMALLbox Installation Complete!
-% 
-%  For more information on the installed toolboxes see
-% 
-%  Sparco: http://www.cs.ubc.ca/labs/scl/sparco/
-% 
-%  SPGL1: http://www.cs.ubc.ca/labs/spgl1/?n=HomePage
-% 
-%  SparseLab: http://sparselab.stanford.edu/   (PLEASE REGISTER SPARSELAB!)
-% 
-%  Sparsify: http://www.see.ed.ac.uk/~tblumens/sparsify/sparsify.html
-% 
-%  GPSR: http://www.lx.it.pt/~mtf/GPSR/
-% 
-%  OMPbox and KSVDBox: http://www.cs.technion.ac.il/~ronrubin/
-% 
-% 
-%  Would you like to run a demo: ([y]/n)? 
-% 
-%  1 to run SMALL_solver_test 
-%  2 to run Dictionary Learning for Image Denoising demo 
-%  q to quit: 1
-% 
-%  Running SMALL_solver_test problem
-% 
-% Example test of SMALL solvers against their counterparts on Sparco problems.
-% 
-% ??? Undefined function or method 'mdwt' for input arguments of type
-% 'double'.
-% 
-% Error in ==> opWavelet>opWavelet_intrnl at 55
-%       [y,l] = mdwt(reshape(x,[m,n]), h, levels);
-% 
-% Error in ==>
-% opWavelet>@(x,mode)opWavelet_intrnl(m,n,family,filter,levels,type,h,x,mode)
-% at 37
-% op = @(x,mode)
-% opWavelet_intrnl(m,n,family,filter,levels,type,h,x,mode);
-% 
-% Error in ==> prob006 at 67
-% data.x0              = data.op.Daubechies(data.signal,2);
-% 
-% Error in ==> generateProblem at 101
-% [data] = eval(sprintf('prob%03d(varargin{:});',index));
-% 
-% Error in ==> SMALL_solver_test at 61
-% SMALL.Problem = generateProblem(6, 'P', 6, 'm', 270,'n',1024,
-% 'show');
-% 
-% Error in ==> SMALLboxSetup at 416
-%     SMALL_solver_test;
-%     
\ No newline at end of file
Binary file doc/smallbox_documentation.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsSKSVD.m	Wed Oct 31 12:10:13 2012 +0000
@@ -0,0 +1,204 @@
+%%  Dictionary Learning for Image Denoising - KSVD vs KSVDS vs SPAMS
+%
+%   *WARNING!* You should have SPAMS in your search path in order for this
+%   script to work.Due to licensing issues SPAMS can not be automatically 
+%   provided in SMALLbox (http://www.di.ens.fr/willow/SPAMS/downloads.html).
+%
+%   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,
+%   add noise and use noisy image to generate training set for dictionary
+%   learning.
+%   Two dictionary learning techniques were compared:
+%   -   KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient
+%              Implementation of the K-SVD Algorithm using Batch Orthogonal
+%              Matching Pursuit", Technical Report - CS, Technion, April 2008.
+%   -   KSVDS - R. Rubinstein, M. Zibulevsky, and M. Elad, "Learning Sparse
+%               Dictionaries for Sparse Signal Approximation", Technical
+%               Report - CS, Technion, June 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.
+%
+%%
+
+clear;
+
+%   If you want to load the image outside of generateImageDenoiseProblem
+%   function uncomment following lines. This can be useful if you want to
+%   denoise more then one image for example.
+
+% TMPpath=pwd;
+% FS=filesep;
+% [pathstr1, name, ext] = fileparts(which('SMALLboxSetup.m'));
+% cd([pathstr1,FS,'data',FS,'images']);
+% [filename,pathname] = uigetfile({'*.png;'},'Select a file containin pre-calculated notes');
+% [pathstr, name, ext] = fileparts(filename);
+% test_image = imread(filename);
+% test_image = double(test_image);
+% cd(TMPpath);
+% SMALL.Problem.name=name;
+
+
+% Defining Image Denoising Problem as Dictionary Learning
+% Problem. As an input we set the number of training patches.
+
+SMALL.Problem = generateImageDenoiseProblem('', 40000);
+
+
+%%
+%   Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary
+
+%   Initialising Dictionary structure
+%   Setting Dictionary structure fields (toolbox, name, param, D and time)
+%   to zero values
+
+SMALL.DL(1)=SMALL_init_DL();
+
+% Defining the parameters needed for dictionary learning
+
+SMALL.DL(1).toolbox = 'KSVD';
+SMALL.DL(1).name = 'ksvd';
+
+%   Defining the parameters for KSVD
+%   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.
+
+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,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'memusage', 'high');
+
+%   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) ImageDenoise_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
+
+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 PSNR after reconstruction
+
+SMALL.solver(1).reconstructed.psnr
+
+%%
+% Use KSVDS Dictionary Learning Algorithm to denoise image
+
+%   Initialising solver structure
+%   Setting solver structure fields (toolbox, name, param, solution,
+%   reconstructed and time) to zero values
+
+SMALL.DL(2)=SMALL_init_DL();
+
+% Defining the parameters needed for dictionary learning
+
+SMALL.DL(2).toolbox = 'KSVDS';
+SMALL.DL(2).name = 'ksvds';
+
+%   Defining the parameters for KSVDS
+%   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 (EDataS). We also impose "double sparsity" - dictionary itself
+%   has to be sparse in the given base dictionary (Tdict - number of
+%   nonzero elements per atom).
+%   Type help ksvds in MATLAB prompt for more options.
+
+EdataS=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain;
+SMALL.DL(2).param=struct(...
+    'Edata', EdataS, ...
+    'Tdict', 6,...
+    'stepsize', 1,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'memusage', 'high');
+SMALL.DL(2).param.initA = speye(SMALL.Problem.p);
+SMALL.DL(2).param.basedict{1} = odctdict(8,16);
+SMALL.DL(2).param.basedict{2} = odctdict(8,16);
+
+% Learn the dictionary
+
+SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2));
+
+%   Set SMALL.Problem.A dictionary and SMALL.Problem.basedictionary
+%   (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.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) ImageDenoise_reconstruct(x, SMALL.Problem, SparseDict);
+
+%   Initialising solver structure
+%   Setting solver structure fields (toolbox, name, param, solution,
+%   reconstructed and time) to zero values
+
+SMALL.solver(2)=SMALL_init_solver;
+
+% Defining the parameters needed for image denoising
+
+SMALL.solver(2).toolbox='ompsbox';
+SMALL.solver(2).name='omps2';
+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));
+
+
+%%
+% Plot results and save midi files
+
+% show results %
+
+SMALL_ImgDeNoiseResult(SMALL);
--- a/examples/Image Denoising/SMALL_ImgDenoise_DL_test_TwoStep_KSVD_MOD_OLS_Mailhe.m	Tue Sep 04 11:00:36 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,309 +0,0 @@
-%%  Dictionary Learning for Image Denoising - KSVD vs Recursive Least Squares
-%
-%   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,
-%   add noise and use noisy image to generate training set for dictionary
-%   learning.
-%   Two dictionary learning techniques were compared:
-%   -   KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient
-%              Implementation of the K-SVD Algorithm using Batch Orthogonal
-%              Matching Pursuit", Technical Report - CS, Technion, April 2008.
-%   -   RLS-DLA - Skretting, K.; Engan, K.; , "Recursive Least Squares
-%       Dictionary Learning Algorithm," Signal Processing, IEEE Transactions on,
-%       vol.58, no.4, pp.2121-2130, April 2010
-%
-
-
-%   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.
-%   
-%%
-
-
-
-%   If you want to load the image outside of generateImageDenoiseProblem
-%   function uncomment following lines. This can be useful if you want to
-%   denoise more then one image for example.
-%   Here we are loading test_image.mat that contains structure with 5 images : lena,
-%   barbara,boat, house and peppers.
-clear;
-TMPpath=pwd;
-FS=filesep;
-[pathstr1, name, ext] = fileparts(which('SMALLboxSetup.m'));
-cd([pathstr1,FS,'data',FS,'images']);
-load('test_image.mat');
-cd(TMPpath);
-
-%   Deffining the noise levels that we want to test
-
-noise_level=[10 20 25 50 100];
-
-%   Here we loop through different noise levels and images 
-
-for noise_ind=2:2
-for im_num=2:2
-
-% Defining Image Denoising Problem as Dictionary Learning
-% Problem. As an input we set the number of training patches.
-
-SMALL.Problem = generateImageDenoiseProblem(test_image(im_num).i, 40000, '',256, noise_level(noise_ind));
-SMALL.Problem.name=int2str(im_num);
-
-Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain;
-maxatoms = floor(prod(SMALL.Problem.blocksize)/2);
-
-
-%%
-%   Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary
-%   Boris Mailhe ksvd update implentation omp is the same as with Rubinstein
-%   implementation
-
-
-%   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
-
-SMALL.solver(1).toolbox='ompbox';
-SMALL.solver(1).name='omp2';
-SMALL.solver(1).param=struct(...
-    'epsilon',Edata,...
-    'maxatoms', maxatoms); 
-
-%   Initialising Dictionary structure
-%   Setting Dictionary structure fields (toolbox, name, param, D and time)
-%   to zero values
-
-SMALL.DL(1)=SMALL_init_DL('TwoStepDL', 'KSVD', '', 1);
-
-
-%   Defining the parameters for KSVD
-%   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,...
-    'show_dict', 1);
-
-%   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) 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
-%   reconstruction function to reconstruct the patches and put them into a
-%   denoised image
-
-SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1));
-
-%%
-%   Use MOD Dictionary Learning Algorithm to Learn overcomplete dictionary
-%   Boris Mailhe MOD update implentation omp is the Ron Rubinstein
-%   implementation
-
-
-%   Initialising solver structure
-%   Setting solver structure fields (toolbox, name, param, solution,
-%   reconstructed and time) to zero values
-
-SMALL.solver(2)=SMALL_init_solver;
-
-% Defining the parameters needed for image denoising
-
-SMALL.solver(2).toolbox='ompbox';
-SMALL.solver(2).name='omp2';
-SMALL.solver(2).param=struct(...
-    'epsilon',Edata,...
-    'maxatoms', maxatoms); 
-
-%   Initialising Dictionary structure
-%   Setting Dictionary structure fields (toolbox, name, param, D and time)
-%   to zero values
-
-SMALL.DL(2)=SMALL_init_DL('TwoStepDL', 'MOD', '', 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(2).param=struct(...
-    'solver', SMALL.solver(2),...
-    'initdict', SMALL.Problem.initdict,...
-    'dictsize', SMALL.Problem.p,...
-    'iternum', 20,...
-    'show_dict', 1);
-
-%   Learn the dictionary
-
-SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2));
-
-%   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(2).D;
-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
-%   reconstruction function to reconstruct the patches and put them into a
-%   denoised image
-
-SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2));
-%%
-%   Use OLS Dictionary Learning Algorithm to Learn overcomplete dictionary
-%   Boris Mailhe ksvd update implentation omp is the Ron Rubinstein
-%   implementation
-
-
-%   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); 
-
-%   Initialising Dictionary structure
-%   Setting Dictionary structure fields (toolbox, name, param, D and time)
-%   to zero values
-
-SMALL.DL(3)=SMALL_init_DL('TwoStepDL', 'ols', '', 1);
-
-
-%   Defining the parameters for KSVD
-%   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(3).param=struct(...
-    'solver', SMALL.solver(3),...
-    'initdict', SMALL.Problem.initdict,...
-    'dictsize', SMALL.Problem.p,...
-    'iternum', 20,...
-    'learningRate', 0.1,...
-    'show_dict', 1);
-
-%   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;
-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
-%   reconstruction function to reconstruct the patches and put them into a
-%   denoised image
-
-SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
-%%
-%   Use Mailhe Dictionary Learning Algorithm to Learn overcomplete dictionary
-%   Boris Mailhe ksvd update implentation omp is the Ron Rubinstein
-%   implementation
-
-
-%   Initialising solver structure
-%   Setting solver structure fields (toolbox, name, param, solution,
-%   reconstructed and time) to zero values
-
-SMALL.solver(4)=SMALL_init_solver;
-
-% Defining the parameters needed for image denoising
-
-SMALL.solver(4).toolbox='ompbox';
-SMALL.solver(4).name='omp2';
-SMALL.solver(4).param=struct(...
-    'epsilon',Edata,...
-    'maxatoms', maxatoms); 
-
-%   Initialising Dictionary structure
-%   Setting Dictionary structure fields (toolbox, name, param, D and time)
-%   to zero values
-
-SMALL.DL(4)=SMALL_init_DL('TwoStepDL', 'opt', '', 1);
-
-
-%   Defining the parameters for KSVD
-%   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(4).param=struct(...
-    'solver', SMALL.solver(4),...
-    'initdict', SMALL.Problem.initdict,...
-    'dictsize', SMALL.Problem.p,...
-    'iternum', 20,...
-    'learningRate', 2,...
-    'show_dict', 1);
-
-%   Learn the dictionary
-
-SMALL.DL(4) = SMALL_learn(SMALL.Problem, SMALL.DL(4));
-
-%   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(4).D;
-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
-%   reconstruction function to reconstruct the patches and put them into a
-%   denoised image
-
-SMALL.solver(4)=SMALL_solve(SMALL.Problem, SMALL.solver(4));
-
-%% show results %%
-
-SMALL_ImgDeNoiseResult(SMALL);
-
-%clear SMALL;
-end
-end
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/Image Denoising/SMALL_ImgDenoise_DL_test_TwoStep_KSVD_MOD_OLS_OPT.m	Wed Oct 31 12:10:13 2012 +0000
@@ -0,0 +1,309 @@
+%%  Dictionary Learning for Image Denoising - KSVD vs Recursive Least Squares
+%
+%   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,
+%   add noise and use noisy image to generate training set for dictionary
+%   learning.
+%   Two dictionary learning techniques were compared:
+%   -   KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient
+%              Implementation of the K-SVD Algorithm using Batch Orthogonal
+%              Matching Pursuit", Technical Report - CS, Technion, April 2008.
+%   -   RLS-DLA - Skretting, K.; Engan, K.; , "Recursive Least Squares
+%       Dictionary Learning Algorithm," Signal Processing, IEEE Transactions on,
+%       vol.58, no.4, pp.2121-2130, April 2010
+%
+
+
+%   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.
+%   
+%%
+
+
+
+%   If you want to load the image outside of generateImageDenoiseProblem
+%   function uncomment following lines. This can be useful if you want to
+%   denoise more then one image for example.
+%   Here we are loading test_image.mat that contains structure with 5 images : lena,
+%   barbara,boat, house and peppers.
+clear;
+TMPpath=pwd;
+FS=filesep;
+[pathstr1, name, ext] = fileparts(which('SMALLboxSetup.m'));
+cd([pathstr1,FS,'data',FS,'images']);
+load('test_image.mat');
+cd(TMPpath);
+
+%   Deffining the noise levels that we want to test
+
+noise_level=[10 20 25 50 100];
+
+%   Here we loop through different noise levels and images 
+
+for noise_ind=2:2
+for im_num=2:2
+
+% Defining Image Denoising Problem as Dictionary Learning
+% Problem. As an input we set the number of training patches.
+
+SMALL.Problem = generateImageDenoiseProblem(test_image(im_num).i, 40000, '',256, noise_level(noise_ind));
+SMALL.Problem.name=int2str(im_num);
+
+Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain;
+maxatoms = floor(prod(SMALL.Problem.blocksize)/2);
+
+
+%%
+%   Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary
+%   Boris Mailhe ksvd update implentation omp is the same as with Rubinstein
+%   implementation
+
+
+%   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
+
+SMALL.solver(1).toolbox='ompbox';
+SMALL.solver(1).name='omp2';
+SMALL.solver(1).param=struct(...
+    'epsilon',Edata,...
+    'maxatoms', maxatoms); 
+
+%   Initialising Dictionary structure
+%   Setting Dictionary structure fields (toolbox, name, param, D and time)
+%   to zero values
+
+SMALL.DL(1)=SMALL_init_DL('TwoStepDL', 'KSVD', '', 1);
+
+
+%   Defining the parameters for KSVD
+%   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,...
+    'show_dict', 1);
+
+%   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) 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
+%   reconstruction function to reconstruct the patches and put them into a
+%   denoised image
+
+SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1));
+
+%%
+%   Use MOD Dictionary Learning Algorithm to Learn overcomplete dictionary
+%   Boris Mailhe MOD update implentation omp is the Ron Rubinstein
+%   implementation
+
+
+%   Initialising solver structure
+%   Setting solver structure fields (toolbox, name, param, solution,
+%   reconstructed and time) to zero values
+
+SMALL.solver(2)=SMALL_init_solver;
+
+% Defining the parameters needed for image denoising
+
+SMALL.solver(2).toolbox='ompbox';
+SMALL.solver(2).name='omp2';
+SMALL.solver(2).param=struct(...
+    'epsilon',Edata,...
+    'maxatoms', maxatoms); 
+
+%   Initialising Dictionary structure
+%   Setting Dictionary structure fields (toolbox, name, param, D and time)
+%   to zero values
+
+SMALL.DL(2)=SMALL_init_DL('TwoStepDL', 'MOD', '', 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(2).param=struct(...
+    'solver', SMALL.solver(2),...
+    'initdict', SMALL.Problem.initdict,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'show_dict', 1);
+
+%   Learn the dictionary
+
+SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2));
+
+%   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(2).D;
+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
+%   reconstruction function to reconstruct the patches and put them into a
+%   denoised image
+
+SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2));
+%%
+%   Use OLS Dictionary Learning Algorithm to Learn overcomplete dictionary
+%   Boris Mailhe ksvd update implentation omp is the Ron Rubinstein
+%   implementation
+
+
+%   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); 
+
+%   Initialising Dictionary structure
+%   Setting Dictionary structure fields (toolbox, name, param, D and time)
+%   to zero values
+
+SMALL.DL(3)=SMALL_init_DL('TwoStepDL', 'ols', '', 1);
+
+
+%   Defining the parameters for KSVD
+%   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(3).param=struct(...
+    'solver', SMALL.solver(3),...
+    'initdict', SMALL.Problem.initdict,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'learningRate', 0.1,...
+    'show_dict', 1);
+
+%   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;
+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
+%   reconstruction function to reconstruct the patches and put them into a
+%   denoised image
+
+SMALL.solver(3)=SMALL_solve(SMALL.Problem, SMALL.solver(3));
+%%
+%   Use Mailhe Dictionary Learning Algorithm to Learn overcomplete dictionary
+%   Boris Mailhe ksvd update implentation omp is the Ron Rubinstein
+%   implementation
+
+
+%   Initialising solver structure
+%   Setting solver structure fields (toolbox, name, param, solution,
+%   reconstructed and time) to zero values
+
+SMALL.solver(4)=SMALL_init_solver;
+
+% Defining the parameters needed for image denoising
+
+SMALL.solver(4).toolbox='ompbox';
+SMALL.solver(4).name='omp2';
+SMALL.solver(4).param=struct(...
+    'epsilon',Edata,...
+    'maxatoms', maxatoms); 
+
+%   Initialising Dictionary structure
+%   Setting Dictionary structure fields (toolbox, name, param, D and time)
+%   to zero values
+
+SMALL.DL(4)=SMALL_init_DL('TwoStepDL', 'opt', '', 1);
+
+
+%   Defining the parameters for KSVD
+%   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(4).param=struct(...
+    'solver', SMALL.solver(4),...
+    'initdict', SMALL.Problem.initdict,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'learningRate', 2,...
+    'show_dict', 1);
+
+%   Learn the dictionary
+
+SMALL.DL(4) = SMALL_learn(SMALL.Problem, SMALL.DL(4));
+
+%   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(4).D;
+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
+%   reconstruction function to reconstruct the patches and put them into a
+%   denoised image
+
+SMALL.solver(4)=SMALL_solve(SMALL.Problem, SMALL.solver(4));
+
+%% show results %%
+
+SMALL_ImgDeNoiseResult(SMALL);
+
+%clear SMALL;
+end
+end
+
--- a/test.m	Tue Sep 04 11:00:36 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-test
\ No newline at end of file