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