comparison examples/AudioInpainting/Audio_Declipping_Example.m @ 136:1334d2302dd9 ivand_dev

Added Audio declipping problem (problem, reconstruct and example function)
author Ivan Damnjanovic lnx <ivan.damnjanovic@eecs.qmul.ac.uk>
date Thu, 14 Jul 2011 16:26:07 +0100
parents
children 9207d56c5547
comparison
equal deleted inserted replaced
134:10343fb66448 136:1334d2302dd9
1 %% Audio Declipping Example
2 %
3 % CHANGE!!! This example is based on the experiment suggested by Professor Pierre
4 % Vandergheynst on the SMALL meeting in Villars.
5 % The idea behind is to use patches from source image as a dictionary in
6 % which we represent target image using matching pursuit algorithm.
7 % Calling Pierre_Problem function to get src image to be used as dictionary
8 % and target image to be represented using MP with 3 patches from source image
9
10 %
11 % Centre for Digital Music, Queen Mary, University of London.
12 % This file copyright 2011 Ivan Damnjanovic.
13 %
14 % This program is free software; you can redistribute it and/or
15 % modify it under the terms of the GNU General Public License as
16 % published by the Free Software Foundation; either version 2 of the
17 % License, or (at your option) any later version. See the file
18 % COPYING included with this distribution for more information.
19 %
20 %%
21
22 clear all;
23
24 % Defining the Problem structure
25
26 SMALL.Problem = generateAudioDeclippingProblem('male01_8kHz.wav', 0.6, 256, 0.5, @wRect, @wSine, @wRect, @Gabor_Dictionary, 2);
27
28 % % Show original image and image that is used as a dictionary
29 % figure('Name', 'Original and Dictionary Image');
30 %
31 % subplot(1,2,1); imagesc(SMALL.Problem.imageTrg/SMALL.Problem.maxval);
32 % title('Original Image');colormap(gray);axis off; axis image;
33 % subplot(1,2,2); imagesc(SMALL.Problem.imageSrc/SMALL.Problem.maxval);
34 % title('Dictionary image:');colormap(gray);axis off; axis image;
35 time=0;
36 coeffFrames = zeros(SMALL.Problem.p, SMALL.Problem.n);
37
38 for i=1:SMALL.Problem.n
39
40 idx = find(SMALL.Problem.M(:,i));
41 SMALL.Problem.A = SMALL.Problem.B(idx,:);
42
43 SMALL.Problem.b1 = SMALL.Problem.b(idx,i);
44
45
46
47 % Defining the parameters sparse representation
48 SMALL.solver=SMALL_init_solver;
49 SMALL.solver.toolbox='ompbox';
50 SMALL.solver.name='omp2';
51
52 SMALL.solver.param=struct(...
53 'epsilon', 0.001,...
54 'maxatoms', 64);
55
56 % Find solution
57
58 SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver);
59
60
61 coeffFrames(:,i) = SMALL.solver.solution;
62 time = time + SMALL.solver.time;
63
64
65
66 end
67
68 %% Set reconstruction function
69
70 SMALL.Problem.reconstruct=@(x) AudioDeclipping_reconstruct(x, SMALL.Problem);
71 reconstructed=SMALL.Problem.reconstruct(coeffFrames);
72
73 %% plot time and psnr given dictionary size %%
74 figure('Name', 'time and psnr');
75
76 subplot(1,2,1); plot(dictsize(1,:), time(1,:), 'ro-');
77 title('Time vs number of source image patches used');
78 subplot(1,2,2); plot(dictsize(1,:), psnr(1,:), 'b*-');
79 title('PSNR vs number of source image patches used');