bmailhe@244
|
1 %% Demostration of the use of the UNLocBox solver to solve an image denoising problem of the SMALLBox form
|
bmailhe@244
|
2 %
|
bmailhe@244
|
3 % argmin_x ||x||_1 such that ||Ax-b||_2 < sima_t
|
bmailhe@244
|
4 %
|
bmailhe@244
|
5 % The dictionary A is first learn using SMALLbox
|
bmailhe@244
|
6 %
|
bmailhe@244
|
7 % Queen Mary University
|
bmailhe@244
|
8 % 29 August 2012
|
bmailhe@244
|
9 % Nathanael Perraudin
|
bmailhe@244
|
10 % nathanael.perraudin@epfl.ch
|
bmailhe@244
|
11
|
bmailhe@244
|
12
|
bmailhe@244
|
13 % % Initialisation
|
bmailhe@244
|
14 % clear all;
|
bmailhe@244
|
15 % close all;
|
bmailhe@244
|
16 % clc;
|
bmailhe@244
|
17
|
bmailhe@244
|
18
|
bmailhe@244
|
19 %% Load an image and create the problem
|
bmailhe@244
|
20
|
bmailhe@244
|
21 % Defining Image Denoising Problem as Dictionary Learning
|
bmailhe@244
|
22 % Problem. As an input we set the number of training patches.
|
bmailhe@244
|
23
|
bmailhe@244
|
24 SMALL.Problem = generateImageDenoiseProblem('', 40000);
|
bmailhe@244
|
25
|
bmailhe@244
|
26
|
bmailhe@244
|
27 %%
|
bmailhe@244
|
28 % Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary
|
bmailhe@244
|
29
|
bmailhe@244
|
30 % Initialising Dictionary structure
|
bmailhe@244
|
31 % Setting Dictionary structure fields (toolbox, name, param, D and time)
|
bmailhe@244
|
32 % to zero values
|
bmailhe@244
|
33
|
bmailhe@244
|
34 SMALL.DL=SMALL_init_DL();
|
bmailhe@244
|
35
|
bmailhe@244
|
36 % Defining the parameters needed for dictionary learning
|
bmailhe@244
|
37
|
bmailhe@244
|
38 SMALL.DL.toolbox = 'KSVD';
|
bmailhe@244
|
39 SMALL.DL.name = 'ksvd';
|
bmailhe@244
|
40
|
bmailhe@244
|
41 % Defining the parameters for KSVD
|
bmailhe@244
|
42 % In this example we are learning 256 atoms in 20 iterations, so that
|
bmailhe@244
|
43 % every patch in the training set can be represented with target error in
|
bmailhe@244
|
44 % L2-norm (EData)
|
bmailhe@244
|
45 % Type help ksvd in MATLAB prompt for more options.
|
bmailhe@244
|
46
|
bmailhe@244
|
47 Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain;
|
bmailhe@244
|
48 maxatoms = floor(prod(SMALL.Problem.blocksize)/2);
|
bmailhe@244
|
49
|
bmailhe@244
|
50 SMALL.DL.param=struct(...
|
bmailhe@244
|
51 'Edata', Edata,...
|
bmailhe@244
|
52 'initdict', SMALL.Problem.initdict,...
|
bmailhe@244
|
53 'dictsize', SMALL.Problem.p,...
|
bmailhe@244
|
54 'iternum', 20,...
|
bmailhe@244
|
55 'memusage', 'high');
|
bmailhe@244
|
56
|
bmailhe@244
|
57 % Learn the dictionary
|
bmailhe@244
|
58
|
bmailhe@244
|
59 SMALL.DL = SMALL_learn(SMALL.Problem, SMALL.DL(1));
|
bmailhe@244
|
60
|
bmailhe@244
|
61 % Set SMALL.Problem.A dictionary
|
bmailhe@244
|
62 % (backward compatiblity with SPARCO: solver structure communicate
|
bmailhe@244
|
63 % only with Problem structure, ie no direct communication between DL and
|
bmailhe@244
|
64 % solver structures)
|
bmailhe@244
|
65
|
bmailhe@244
|
66 SMALL.Problem.A = SMALL.DL.D;
|
bmailhe@244
|
67 SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem);
|
bmailhe@244
|
68
|
bmailhe@244
|
69 %% Solving the problem with UNLocBox
|
bmailhe@244
|
70 % This might not be the better way to solve the problem...
|
bmailhe@244
|
71
|
bmailhe@244
|
72
|
bmailhe@244
|
73 % Set the different parameter
|
bmailhe@244
|
74
|
bmailhe@244
|
75 SMALL.solver=SMALL_init_solver; % Initialisation
|
bmailhe@244
|
76 SMALL.solver.toolbox='UNLocBox'; % select the UNLocBox solver
|
bmailhe@244
|
77 SMALL.solver.name='Douglas_Rachford'; % 'Forward_Backard' 'ADMM' Warning forward backward still need some review...
|
bmailhe@244
|
78 SMALL.solver.param.sigma=1.15*sqrt(SMALL.Problem.m*SMALL.Problem.n)*SMALL.Problem.sigma; % set the radius of the ball
|
bmailhe@244
|
79 SMALL.solver.param.max_iter=100;
|
bmailhe@244
|
80
|
bmailhe@244
|
81
|
bmailhe@244
|
82 SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver);
|
bmailhe@244
|
83
|
bmailhe@244
|
84
|
bmailhe@244
|
85 SMALL_ImgDeNoiseResult(SMALL); |