ivan@136: %% Audio Declipping Example ivan@136: % ivan@136: % CHANGE!!! This example is based on the experiment suggested by Professor Pierre ivan@136: % Vandergheynst on the SMALL meeting in Villars. ivan@136: % The idea behind is to use patches from source image as a dictionary in ivan@136: % which we represent target image using matching pursuit algorithm. ivan@136: % Calling Pierre_Problem function to get src image to be used as dictionary ivan@136: % and target image to be represented using MP with 3 patches from source image ivan@136: ivan@136: % ivan@136: % Centre for Digital Music, Queen Mary, University of London. ivan@136: % This file copyright 2011 Ivan Damnjanovic. ivan@136: % ivan@136: % This program is free software; you can redistribute it and/or ivan@136: % modify it under the terms of the GNU General Public License as ivan@136: % published by the Free Software Foundation; either version 2 of the ivan@136: % License, or (at your option) any later version. See the file ivan@136: % COPYING included with this distribution for more information. ivan@136: % ivan@136: %% ivan@136: ivan@136: clear all; ivan@136: ivan@136: % Defining the Problem structure ivan@136: ivan@136: SMALL.Problem = generateAudioDeclippingProblem('male01_8kHz.wav', 0.6, 256, 0.5, @wRect, @wSine, @wRect, @Gabor_Dictionary, 2); ivan@136: ivan@136: % % Show original image and image that is used as a dictionary ivan@136: % figure('Name', 'Original and Dictionary Image'); ivan@136: % ivan@136: % subplot(1,2,1); imagesc(SMALL.Problem.imageTrg/SMALL.Problem.maxval); ivan@136: % title('Original Image');colormap(gray);axis off; axis image; ivan@136: % subplot(1,2,2); imagesc(SMALL.Problem.imageSrc/SMALL.Problem.maxval); ivan@136: % title('Dictionary image:');colormap(gray);axis off; axis image; ivan@136: time=0; ivan@136: coeffFrames = zeros(SMALL.Problem.p, SMALL.Problem.n); ivan@136: ivan@136: for i=1:SMALL.Problem.n ivan@136: ivan@136: idx = find(SMALL.Problem.M(:,i)); ivan@136: SMALL.Problem.A = SMALL.Problem.B(idx,:); ivan@136: ivan@136: SMALL.Problem.b1 = SMALL.Problem.b(idx,i); ivan@136: ivan@136: ivan@136: ivan@136: % Defining the parameters sparse representation ivan@136: SMALL.solver=SMALL_init_solver; ivan@136: SMALL.solver.toolbox='ompbox'; ivan@136: SMALL.solver.name='omp2'; ivan@136: ivan@136: SMALL.solver.param=struct(... ivan@136: 'epsilon', 0.001,... ivan@136: 'maxatoms', 64); ivan@136: ivan@136: % Find solution ivan@136: ivan@136: SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver); ivan@136: ivan@136: ivan@136: coeffFrames(:,i) = SMALL.solver.solution; ivan@136: time = time + SMALL.solver.time; ivan@136: ivan@136: ivan@136: ivan@136: end ivan@136: ivan@136: %% Set reconstruction function ivan@136: ivan@136: SMALL.Problem.reconstruct=@(x) AudioDeclipping_reconstruct(x, SMALL.Problem); ivan@136: reconstructed=SMALL.Problem.reconstruct(coeffFrames); ivan@136: ivan@136: %% plot time and psnr given dictionary size %% ivan@136: figure('Name', 'time and psnr'); ivan@136: ivan@136: subplot(1,2,1); plot(dictsize(1,:), time(1,:), 'ro-'); ivan@136: title('Time vs number of source image patches used'); ivan@136: subplot(1,2,2); plot(dictsize(1,:), psnr(1,:), 'b*-'); ivan@136: title('PSNR vs number of source image patches used');