comparison examples/MajorizationMinimization tests/SMALL_AudioDenoise_DL_test_KSVDvsSPAMS.m @ 161:f42aa8bcb82f ivand_dev

debug and clean the SMALLbox Problems code
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Wed, 31 Aug 2011 12:02:19 +0100
parents
children 4337e28183f1
comparison
equal deleted inserted replaced
155:b14209313ba4 161:f42aa8bcb82f
1 %% DICTIONARY LEARNING FOR AUDIO DENOISING
2 % This file contains an example of how SMALLbox can be used to test different
3 % dictionary learning techniques in Audio Denoising problem.
4 % It calls generateAudioDenoiseProblem that will let you to choose audio file,
5 % add noise and use noisy audio to generate training set for dictionary
6 % learning.
7 %
8 %
9 % Centre for Digital Music, Queen Mary, University of London.
10 % This file copyright 2011 Ivan Damnjanovic.
11 %
12 % This program is free software; you can redistribute it and/or
13 % modify it under the terms of the GNU General Public License as
14 % published by the Free Software Foundation; either version 2 of the
15 % License, or (at your option) any later version. See the file
16 % COPYING included with this distribution for more information.
17 %
18 %%
19
20 clear;
21
22 % Defining Audio Denoising Problem as Dictionary Learning
23 % Problem
24
25 SMALL.Problem = generateAudioDenoiseProblem('male01_8kHz',0.1,512,1/128,'','','',4);
26
27 %%
28 % Initialising solver structure
29 % Setting solver structure fields (toolbox, name, param, solution,
30 % reconstructed and time) to zero values
31
32 SMALL.solver(1)=SMALL_init_solver('MMbox', 'mm1', '', 1);
33
34 % Defining the parameters needed for image denoising
35
36 SMALL.solver(1).param=struct(...
37 'lambda', 0.2,...
38 'epsilon', 3*10^-4,...
39 'iternum',10);
40
41 % Initialising Dictionary structure
42 % Setting Dictionary structure fields (toolbox, name, param, D and time)
43 % to zero values
44
45 SMALL.DL(1)=SMALL_init_DL('MMbox', 'MM_cn', '', 1);
46
47
48 % Defining the parameters for MOD
49 % In this example we are learning 256 atoms in 20 iterations, so that
50 % every patch in the training set can be represented with target error in
51 % L2-norm (EData)
52 % Type help ksvd in MATLAB prompt for more options.
53
54
55 SMALL.DL(1).param=struct(...
56 'solver', SMALL.solver(1),...
57 'initdict', SMALL.Problem.initdict,...
58 'dictsize', SMALL.Problem.p,...
59 'iternum', 20,...
60 'iterDictUpdate', 10,...
61 'epsDictUpdate', 10^-7,...
62 'cvset',0,...
63 'show_dict', 0);
64
65 % Learn the dictionary
66
67 SMALL.DL(1) = SMALL_learn(SMALL.Problem, SMALL.DL(1));
68
69 % Set SMALL.Problem.A dictionary
70 % (backward compatiblity with SPARCO: solver structure communicate
71 % only with Problem structure, ie no direct communication between DL and
72 % solver structures)
73
74 SMALL.Problem.A = SMALL.DL(1).D;
75 SMALL.Problem.reconstruct = @(x) AudioDenoise_reconstruct(x, SMALL.Problem);
76 % Denoising the image - find the sparse solution in the learned
77 % dictionary for all patches in the image and the end it uses
78 % reconstruction function to reconstruct the patches and put them into a
79 % denoised image
80
81 SMALL.solver(1)=SMALL_solve(SMALL.Problem, SMALL.solver(1));
82
83 %%
84 %%
85 % % sparse coding using SPAMS online dictionary learning
86 %
87
88 SMALL.DL(2)=SMALL_init_DL();
89 SMALL.DL(2).toolbox = 'SPAMS';
90 SMALL.DL(2).name = 'mexTrainDL';
91 SMALL.DL(2).param=struct('D', SMALL.Problem.initdict, 'K', SMALL.Problem.p, 'lambda', 0.2, 'iter', 200, 'mode', 3, 'modeD', 0);
92
93
94 SMALL.DL(2) = SMALL_learn(SMALL.Problem, SMALL.DL(2));
95
96 % Defining Reconstruction function
97
98 SMALL.Problem.A = SMALL.DL(2).D;
99
100
101 %%
102 % Initialising solver structure
103 % Setting toolbox, name, param, solution, reconstructed and time to zero values
104
105 SMALL.solver(2)=SMALL_init_solver;
106
107 % Defining the parameters needed for sparse representation
108
109 SMALL.solver(2).toolbox='ompbox';
110 SMALL.solver(2).name='omp2';
111 SMALL.solver(2).param=struct(...
112 'epsilon',0.2,...
113 'maxatoms', 128);
114 % Represent Training set in the learned dictionary
115
116 SMALL.solver(2)=SMALL_solve(SMALL.Problem, SMALL.solver(2));
117
118
119
120
121 %%
122 % Plot results and save midi files
123
124 % show results %
125
126
127 SMALL_AudioDeNoiseResult(SMALL);
128