-
Notifications
You must be signed in to change notification settings - Fork 8
/
demo.m
59 lines (42 loc) · 1.46 KB
/
demo.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
addpath(genpath('DAEs'))
% select denoiser
denoiser_name = 'caffe'; % make sure matCaffe is installed and its location is added to path
% denoiser_name = 'matconvnet'; % make sure matconvnet is installed and its location is added to path
% set to 0 if you want to run on CPU (very slow)
use_gpu = 1;
% use_gpu = 0;
%% Load data
% load image and kernel
load('data/kernels.mat');
gt = double(imread('data/101085.jpg'));
kernel = kernels{1};
sigma_d = 255 * .01;
degraded = convn(gt, rot90(kernel,2), 'valid');
noise = randn(size(degraded));
degraded = degraded + noise * sigma_d;
% load denoiser for solver
params.denoiser = loadDenoiser(denoiser_name, use_gpu, size(gt));
% set parameters
params.sigma_dae = 11; % correspones to the denoiser's training standard deviation
params.num_iter = 300; % number of iterations
params.gt = gt; % to print PSNR at each iteration
%% non-blind deblurring demo
% run DMSP
restored = DMSPDeblur(degraded, kernel, sigma_d, params);
figure;
subplot(131);
imshow(gt/255); title('Ground Truth')
subplot(132);
imshow(degraded/255); title('Blurry')
subplot(133);
imshow(restored/255); title('Restored')
%% Noise-blind deblurring demo
% run DMSP noise-blind
restored_nb = DMSPDeblur(degraded, kernel, -1, params);
figure;
subplot(131);
imshow(gt/255); title('Ground Truth')
subplot(132);
imshow(degraded/255); title('Blurry')
subplot(133);
imshow(restored_nb/255); title('Restored (noise-blind)')