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 (current diff) 5c8bcdadb380 (diff)
children ecce33192fcc
files SMALLboxSetup.m
diffstat 8 files changed, 198 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/SMALLboxSetup.m	Wed Oct 31 11:53:07 2012 +0000
+++ b/SMALLboxSetup.m	Wed Oct 31 12:10:13 2012 +0000
@@ -421,6 +421,34 @@
     end
     cd(SMALL_path);
 end
+
+%% UnlocBox setup
+if ~exist('init_unlocbox.m','file')
+    fprintf('\n ******************************************************************');
+    fprintf('\n\n Initialising UNLocBox Setup');
+    
+    try
+        UNL_path = [pwd,FS,'toolboxes',FS,'UNLocBox'];
+        if exist([UNL_path, FS, 'toolbox_lastest.zip'],'file'),
+            UNL_zip=[UNL_path, FS, 'toolbox_latest.zip'];
+        else
+            UNL_zip='http://wiki.epfl.ch/unlocbox/documents/toolbox_latest.zip';
+            fprintf('\n\n Downloading toolbox, please be patient\n\n');
+        end
+        unzip(UNL_zip,UNL_path);
+        UNL_p=genpath(UNL_path);
+        addpath(UNL_p);
+        fprintf('\n UNLocBox Installation Successful!\n');
+    catch
+        fprintf('\n UNLocBox Installation Failed\n');
+        cd(SMALL_path);
+    end
+    cd(SMALL_path);
+else
+    fprintf('\n ******************************************************************');
+    fprintf('\n\n UNLocBox is already installed');
+end
+
 %%
 fprintf('\n ******************************************************************');
 fprintf('\n\n Initialising SMALLbox Examples Setup');
--- a/config/SMALL_solve_config.m	Wed Oct 31 11:53:07 2012 +0000
+++ b/config/SMALL_solve_config.m	Wed Oct 31 12:10:13 2012 +0000
@@ -74,6 +74,14 @@
     end
     
     [y, cost] = wrapper_mm_solver(b, A, solver.param);
+
+elseif (strcmpi(solver.toolbox, 'UNLocBox'))
+    if ~isa(Problem.A,'float')
+        % MMbox does not accept implicit dictionary definition
+        A = opToMatrix(Problem.A, 1);
+    end
+    
+    y = unloc_solver(b, A, solver.param,solver.name);
     
     %%
     %   Please do not make any changes to the 'SMALL_solve_config.m' file
Binary file data/images/lena_little.png has changed
--- a/examples/AudioInpainting/Audio_Declipping_Example.m	Wed Oct 31 11:53:07 2012 +0000
+++ b/examples/AudioInpainting/Audio_Declipping_Example.m	Wed Oct 31 12:10:13 2012 +0000
@@ -49,7 +49,7 @@
 
 %   Defining the Problem structure
 
-SMALL.Problem = generateAudioDeclippingProblem('male01_8kHz', 0.6, 256, 0.5, @wRect, @wSine, @wRect, @Gabor_Dictionary, 2);
+SMALL.Problem = generateAudioDeclippingProblem('male01_8kHz', 0.1, 256, 0.5, @wRect, @wSine, @wRect, @Gabor_Dictionary, 2);
 
 for idxSolver = 1:4
     
--- a/examples/AudioInpainting/CVX_add_const_Audio_declipping.m	Wed Oct 31 11:53:07 2012 +0000
+++ b/examples/AudioInpainting/CVX_add_const_Audio_declipping.m	Wed Oct 31 12:10:13 2012 +0000
@@ -56,7 +56,7 @@
             cvx_begin
             cvx_quiet(true)
             variable solution(j)
-            minimize(norm(Dict(:,idxCoeff)*solution-xObs))
+            minimize(norm(Dict(:,idxCoeff)*solution-signal))
             cvx_end
         end
     else
@@ -75,7 +75,7 @@
             cvx_begin
             cvx_quiet(true)
             variable solution(j)
-            minimize(norm(Dict(:,idxCoeff)*solution-xObs))
+            minimize(norm(Dict(:,idxCoeff)*solution-signal))
             cvx_end
         end
     end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/Image Denoising/SMALL_ImgDenoise_UNLocBox.m	Wed Oct 31 12:10:13 2012 +0000
@@ -0,0 +1,85 @@
+%% Demostration of the use of the UNLocBox solver to solve an image denoising problem of the SMALLBox form
+%
+% argmin_x ||x||_1 such that ||Ax-b||_2 < sima_t
+%
+%   The dictionary A is first learn using SMALLbox
+%
+% Queen Mary University
+% 29 August 2012
+% Nathanael Perraudin
+% nathanael.perraudin@epfl.ch
+
+
+% % Initialisation
+% clear all;
+% close all;
+% clc;
+
+
+%% Load an image and create the problem
+
+% 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=SMALL_init_DL();
+
+% Defining the parameters needed for dictionary learning
+
+SMALL.DL.toolbox = 'KSVD';
+SMALL.DL.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.param=struct(...
+    'Edata', Edata,...
+    'initdict', SMALL.Problem.initdict,...
+    'dictsize', SMALL.Problem.p,...
+    'iternum', 20,...
+    'memusage', 'high');
+
+%   Learn the dictionary
+
+SMALL.DL = 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.D;
+SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem);
+
+%% Solving the problem with UNLocBox
+% This might not be the better way to solve the problem...
+
+
+% Set the different parameter
+
+SMALL.solver=SMALL_init_solver; % Initialisation
+SMALL.solver.toolbox='UNLocBox';     % select the UNLocBox solver
+SMALL.solver.name='Douglas_Rachford'; % 'Forward_Backard' 'ADMM' Warning forward backward still need some review...
+SMALL.solver.param.sigma=1.15*sqrt(SMALL.Problem.m*SMALL.Problem.n)*SMALL.Problem.sigma; % set the radius of the ball
+SMALL.solver.param.max_iter=100;
+
+
+SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver);
+
+
+SMALL_ImgDeNoiseResult(SMALL);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/small_to_unloc.m	Wed Oct 31 12:10:13 2012 +0000
@@ -0,0 +1,43 @@
+function [b2,f1,f2,param] = small_to_unloc(b,A,param)
+    
+
+    if nargin<3, param=struct; end
+    % set parameters
+    if ~isfield(param, 'verbose'), param.verbose = 0; end
+    if ~isfield(param, 'T'), param.T = 1; end
+    if ~isfield(param, 'gamma'), param.gamma = 1/(1.1*norm(A)^2); end
+    if ~isfield(param, 'sigma'), param.sigma = 1; end
+    
+    
+    %set function f2
+    param_f2.verbose=param.verbose;
+    param_f2.A=@(x) A*x;
+    param_f2.At=@(x) A'*x;
+    param_f2.y=b;
+    param_f2.tight=0;
+    param_f2.nu=norm(A,2)^2;
+    param_f2.epsilon=param.sigma;
+    
+    f2.prox= @(x,l) fast_proj_B2(x,l,param_f2); % douglas rachford, admm
+    f2.grad= @(x) 2*A'*(A*x-b); %forward backward
+    f2.x0=A'*b;
+    f2.norm=@(x) 0;
+    
+    
+    
+    
+    %set function f1
+    param_f1.verbose=param.verbose;
+    
+    f1.x0=A'*b;
+    f1.norm= @(x) sum(sum(abs(x)));
+    f1.prox= @(x,l) prox_L1(x,param.T*l,param_f1);
+    
+    
+    
+    %set initial point
+    b2=A'*b;
+    
+    
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/unloc_solver.m	Wed Oct 31 12:10:13 2012 +0000
@@ -0,0 +1,31 @@
+function [ sol ] = unloc_solver( b, A, param,name )
+%UNLOC_SOLVER Solve the minimisation problem using UNLOCBOX toolbox
+%
+% argmin_x ||x||_1 such that ||Ax-b||_2 < sima_t
+
+if nargin<3, param=struct; end
+
+% set parameters
+if ~isfield(param, 'verbose'), param.verbose = 1; end
+if ~isfield(param, 'T'), param.T = 256; end
+if ~isfield(param, 'sigma'), param.sigma = 1; end
+if ~isfield(param, 'max_iter'), param.max_iter = 100; end
+if ~isfield(param, 'epsilon'), param.epsilon = 1e-3; end
+
+[b2,f1,f2,param] = small_to_unloc(b,A,param); 
+
+if strcmpi(name, 'Douglas_Rachford')    
+    sol=douglas_rachford(b2,f2,f1,param);
+elseif strcmpi(name, 'Forward_Backard')    
+    sol=forward_backward(b2,f1,f2,param);
+elseif strcmpi(name, 'ADMM')  
+    opL= @(x) x;
+    sol=admm(b2,f1,f2,opL,param);
+else
+    error('UNLocBox tells you: Unknown solver name!')
+end;
+
+
+
+end
+