view 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
line wrap: on
line source
%%  Audio Declipping Example
%   
%   CHANGE!!! This example is based on the experiment suggested by Professor Pierre
%   Vandergheynst on the SMALL meeting in Villars.
%   The idea behind is to use patches from source image as a dictionary in
%   which we represent target image using matching pursuit algorithm.
%   Calling Pierre_Problem function to get src image to be used as dictionary
%   and target image to be represented using MP with 3 patches from source image

%
%   Centre for Digital Music, Queen Mary, University of London.
%   This file copyright 2011 Ivan Damnjanovic.
%
%   This program is free software; you can redistribute it and/or
%   modify it under the terms of the GNU General Public License as
%   published by the Free Software Foundation; either version 2 of the
%   License, or (at your option) any later version.  See the file
%   COPYING included with this distribution for more information.
%
%%

clear all;

%   Defining the Problem structure

SMALL.Problem = generateAudioDeclippingProblem('male01_8kHz.wav', 0.6, 256, 0.5, @wRect, @wSine, @wRect, @Gabor_Dictionary, 2);

% %   Show original image and image that is used as a dictionary
% figure('Name', 'Original and Dictionary Image');
% 
% subplot(1,2,1); imagesc(SMALL.Problem.imageTrg/SMALL.Problem.maxval);
% title('Original Image');colormap(gray);axis off; axis image;
% subplot(1,2,2); imagesc(SMALL.Problem.imageSrc/SMALL.Problem.maxval);
% title('Dictionary image:');colormap(gray);axis off; axis image;
time=0;
coeffFrames = zeros(SMALL.Problem.p, SMALL.Problem.n);

for i=1:SMALL.Problem.n
    
    idx = find(SMALL.Problem.M(:,i));
    SMALL.Problem.A  = SMALL.Problem.B(idx,:);
    
    SMALL.Problem.b1 = SMALL.Problem.b(idx,i);
    
   
    
    %   Defining the parameters sparse representation
    SMALL.solver=SMALL_init_solver;
    SMALL.solver.toolbox='ompbox';
    SMALL.solver.name='omp2';
    
    SMALL.solver.param=struct(...
        'epsilon', 0.001,...
        'maxatoms', 64); 
    
    % Find solution
    
    SMALL.solver=SMALL_solve(SMALL.Problem, SMALL.solver);
    
    
    coeffFrames(:,i) = SMALL.solver.solution;
    time = time + SMALL.solver.time;
    
    
      
end

%%   Set reconstruction function

SMALL.Problem.reconstruct=@(x) AudioDeclipping_reconstruct(x, SMALL.Problem);
reconstructed=SMALL.Problem.reconstruct(coeffFrames);

%%  plot time and psnr given dictionary size %%
figure('Name', 'time and psnr');

subplot(1,2,1); plot(dictsize(1,:), time(1,:), 'ro-');
title('Time vs number of source image patches used');
subplot(1,2,2); plot(dictsize(1,:), psnr(1,:), 'b*-');
title('PSNR vs number of source image patches used');