bmailhe@244: %% Demostration of the use of the UNLocBox solver to solve an image denoising problem of the SMALLBox form bmailhe@244: % bmailhe@244: % argmin_x ||x||_1 such that ||Ax-b||_2 < sima_t bmailhe@244: % bmailhe@244: % The dictionary A is first learn using SMALLbox bmailhe@244: % bmailhe@244: % Queen Mary University bmailhe@244: % 29 August 2012 bmailhe@244: % Nathanael Perraudin bmailhe@244: % nathanael.perraudin@epfl.ch bmailhe@244: bmailhe@244: bmailhe@244: % % Initialisation bmailhe@244: % clear all; bmailhe@244: % close all; bmailhe@244: % clc; bmailhe@244: bmailhe@244: bmailhe@244: %% Load an image and create the problem bmailhe@244: bmailhe@244: % Defining Image Denoising Problem as Dictionary Learning bmailhe@244: % Problem. As an input we set the number of training patches. bmailhe@244: bmailhe@244: SMALL.Problem = generateImageDenoiseProblem('', 40000); bmailhe@244: bmailhe@244: bmailhe@244: %% bmailhe@244: % Use KSVD Dictionary Learning Algorithm to Learn overcomplete dictionary bmailhe@244: bmailhe@244: % Initialising Dictionary structure bmailhe@244: % Setting Dictionary structure fields (toolbox, name, param, D and time) bmailhe@244: % to zero values bmailhe@244: bmailhe@244: SMALL.DL=SMALL_init_DL(); bmailhe@244: bmailhe@244: % Defining the parameters needed for dictionary learning bmailhe@244: bmailhe@244: SMALL.DL.toolbox = 'KSVD'; bmailhe@244: SMALL.DL.name = 'ksvd'; bmailhe@244: bmailhe@244: % Defining the parameters for KSVD bmailhe@244: % In this example we are learning 256 atoms in 20 iterations, so that bmailhe@244: % every patch in the training set can be represented with target error in bmailhe@244: % L2-norm (EData) bmailhe@244: % Type help ksvd in MATLAB prompt for more options. bmailhe@244: bmailhe@244: Edata=sqrt(prod(SMALL.Problem.blocksize)) * SMALL.Problem.sigma * SMALL.Problem.gain; bmailhe@244: maxatoms = floor(prod(SMALL.Problem.blocksize)/2); bmailhe@244: bmailhe@244: SMALL.DL.param=struct(... bmailhe@244: 'Edata', Edata,... bmailhe@244: 'initdict', SMALL.Problem.initdict,... bmailhe@244: 'dictsize', SMALL.Problem.p,... bmailhe@244: 'iternum', 20,... bmailhe@244: 'memusage', 'high'); bmailhe@244: bmailhe@244: % Learn the dictionary bmailhe@244: bmailhe@244: SMALL.DL = SMALL_learn(SMALL.Problem, SMALL.DL(1)); bmailhe@244: bmailhe@244: % Set SMALL.Problem.A dictionary bmailhe@244: % (backward compatiblity with SPARCO: solver structure communicate bmailhe@244: % only with Problem structure, ie no direct communication between DL and bmailhe@244: % solver structures) bmailhe@244: bmailhe@244: SMALL.Problem.A = SMALL.DL.D; bmailhe@244: SMALL.Problem.reconstruct = @(x) ImageDenoise_reconstruct(x, SMALL.Problem); bmailhe@244: bmailhe@244: %% Solving the problem with UNLocBox bmailhe@244: % This might not be the better way to solve the problem... bmailhe@244: bmailhe@244: bmailhe@244: % Set the different parameter bmailhe@244: bmailhe@244: SMALL.solver=SMALL_init_solver; % Initialisation bmailhe@244: SMALL.solver.toolbox='UNLocBox'; % select the UNLocBox solver bmailhe@244: SMALL.solver.name='Douglas_Rachford'; % 'Forward_Backard' 'ADMM' Warning forward backward still need some review... bmailhe@244: SMALL.solver.param.sigma=1.15*sqrt(SMALL.Problem.m*SMALL.Problem.n)*SMALL.Problem.sigma; % set the radius of the ball bmailhe@244: SMALL.solver.param.max_iter=100; bmailhe@244: bmailhe@244: bmailhe@244: SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver); bmailhe@244: bmailhe@244: bmailhe@244: SMALL_ImgDeNoiseResult(SMALL);