comparison examples/Image Denoising/SMALL_ImgDenoise_DL_test_KSVDvsRLSDLA.m @ 83:4302a91e6033

couple of comment lines added
author Maria Jafari <maria.jafari@eecs.qmul.ac.uk>
date Fri, 01 Apr 2011 12:11:16 +0100
parents 62f20b91d870
children 67aae1283973
comparison
equal deleted inserted replaced
82:138f7f0fdcdf 83:4302a91e6033
2 % This file contains an example of how SMALLbox can be used to test different 2 % This file contains an example of how SMALLbox can be used to test different
3 % dictionary learning techniques in Image Denoising problem. 3 % dictionary learning techniques in Image Denoising problem.
4 % It calls generateImageDenoiseProblem that will let you to choose image, 4 % It calls generateImageDenoiseProblem that will let you to choose image,
5 % add noise and use noisy image to generate training set for dictionary 5 % add noise and use noisy image to generate training set for dictionary
6 % learning. 6 % learning.
7 % Three dictionary learning techniques were compared: 7 % Two dictionary learning techniques were compared:
8 % - KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient 8 % - KSVD - M. Elad, R. Rubinstein, and M. Zibulevsky, "Efficient
9 % Implementation of the K-SVD Algorithm using Batch Orthogonal 9 % Implementation of the K-SVD Algorithm using Batch Orthogonal
10 % Matching Pursuit", Technical Report - CS, Technion, April 2008. 10 % Matching Pursuit", Technical Report - CS, Technion, April 2008.
11 % - KSVDS - R. Rubinstein, M. Zibulevsky, and M. Elad, "Learning Sparse 11 % - RLS-DLA - Skretting, K.; Engan, K.; , "Recursive Least Squares
12 % Dictionaries for Sparse Signal Approximation", Technical 12 % Dictionary Learning Algorithm," Signal Processing, IEEE Transactions on,
13 % Report - CS, Technion, June 2009. 13 % vol.58, no.4, pp.2121-2130, April 2010
14 % - SPAMS - J. Mairal, F. Bach, J. Ponce and G. Sapiro. Online
15 % Dictionary Learning for Sparse Coding. International
16 % Conference on Machine Learning,Montreal, Canada, 2009
17 % 14 %
15
16
17 % Centre for Digital Music, Queen Mary, University of London.
18 % This file copyright 2011 Ivan Damnjanovic.
18 % 19 %
19 % Ivan Damnjanovic 2010 20 % This program is free software; you can redistribute it and/or
21 % modify it under the terms of the GNU General Public License as
22 % published by the Free Software Foundation; either version 2 of the
23 % License, or (at your option) any later version. See the file
24 % COPYING included with this distribution for more information.
25 %
20 %% 26 %%
21 27
22 28
23 29
24 % If you want to load the image outside of generateImageDenoiseProblem 30 % If you want to load the image outside of generateImageDenoiseProblem
25 % function uncomment following lines. This can be useful if you want to 31 % function uncomment following lines. This can be useful if you want to
26 % denoise more then one image for example. 32 % denoise more then one image for example.
33 % Here we are loading test_image.mat that contains structure with 5 images : lena,
34 % barbara,boat, house and peppers.
27 clear; 35 clear;
28 TMPpath=pwd; 36 TMPpath=pwd;
29 FS=filesep; 37 FS=filesep;
30 [pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m')); 38 [pathstr1, name, ext, versn] = fileparts(which('SMALLboxSetup.m'));
31 cd([pathstr1,FS,'data',FS,'images']); 39 cd([pathstr1,FS,'data',FS,'images']);
32 load('test_image.mat'); 40 load('test_image.mat');
33 cd(TMPpath); 41 cd(TMPpath);
34 % [filename,pathname] = uigetfile({'*.png;'},'Select a file containin pre-calculated notes'); 42
35 % [pathstr, name, ext, versn] = fileparts(filename); 43 % Deffining the noise levels that we want to test
36 % test_image = imread(filename);
37 % test_image = double(test_image);
38 % cd(TMPpath);
39 % SMALL.Problem.name=name;
40 44
41 noise_level=[10 20 25 50 100]; 45 noise_level=[10 20 25 50 100];
46
47 % Here we loop through different noise levels and images
48
49 for noise_ind=2:2
50 for im_num=1:1
51
42 % Defining Image Denoising Problem as Dictionary Learning 52 % Defining Image Denoising Problem as Dictionary Learning
43 % Problem. As an input we set the number of training patches. 53 % Problem. As an input we set the number of training patches.
44 for noise_ind=1:1 54
45 for im_num=2:2
46 SMALL.Problem = generateImageDenoiseProblem(test_image(im_num).i, 40000, '',256, noise_level(noise_ind)); 55 SMALL.Problem = generateImageDenoiseProblem(test_image(im_num).i, 40000, '',256, noise_level(noise_ind));
47 SMALL.Problem.name=int2str(im_num); 56 SMALL.Problem.name=int2str(im_num);
48 57
49 results(noise_ind,im_num).noisy_psnr=SMALL.Problem.noisy_psnr; 58 results(noise_ind,im_num).noisy_psnr=SMALL.Problem.noisy_psnr;
50 59
187 196
188 X=SMALL.Problem.b1; 197 X=SMALL.Problem.b1;
189 X_norm=sqrt(sum(X.^2, 1)); 198 X_norm=sqrt(sum(X.^2, 1));
190 [X_norm_sort, p]=sort(X_norm); 199 [X_norm_sort, p]=sort(X_norm);
191 p1=p(X_norm_sort>Edata); 200 p1=p(X_norm_sort>Edata);
192 if size(p1,2)>140000 201 if size(p1,2)>40000
193 p2 = randperm(size(p1,2)); 202 p2 = randperm(size(p1,2));
194 p2=sort(p2(1:40000)); 203 p2=sort(p2(1:40000));
195 size(p2,2) 204 size(p2,2)
196 SMALL.Problem.b=X(:,p1(p2)); 205 SMALL.Problem.b=X(:,p1(p2));
197 else 206 else