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