-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_Gauss.m
executable file
·115 lines (82 loc) · 2.27 KB
/
demo_Gauss.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
close all;
clear;
clc;
disp('Gaussian blur with Gaussian noise');
xs = im2double(imread('images/barbara_face.png'));
% noisy motion blurry
noise_mean = 0;
noise_var = 0.00001;
% default padding is 'replicate'
f = @(x) imgaussfilt(x, 3, 'Padding', 'circular');
F = @(x) imnoise(f(x),'gaussian',noise_mean,noise_var);
y = F(xs);
% Sample the kernel for Wiener and deconv-tv
d = zeros(11, 11);
d(6,6) = 1.0;
h = f(d);
h = h./sum(h(:));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Wiener
signal_var = var(y(:));
NSR = noise_var / signal_var;
g = @(x) deconvwnr(x,h,NSR);
W = g(y);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regular Tao
opts.maxiter = 20;
[T, ~] = Tao_orig(F, y, opts);
%T = T(ps+1:end-ps,ps+1:end-ps,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Phase corrected
[Tc, ~] = pcVC(F, y);
%Tc = Tc(ps+1:end-ps,ps+1:end-ps,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% modified Wiener
[iW, ~] = mW(F, y);
%iW = iW(ps+1:end-ps,ps+1:end-ps,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% LM
[lm, ~] = mLM(F, y);
%lm = lm(ps+1:end-ps,ps+1:end-ps,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dfl_opts.maxiter = 500; % follows the paper
[dfL, ~] = aL(F, y, dfl_opts); % approximate Landweber
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[mrl, ~] = mRL(F, y); % modified Richardson-Lucy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Print psnr
% Note: the padding seems to affect the psnr
fprintf("PSNR of Wiener: %f\n", psnr(W, xs));
fprintf("PSNR of (original) Tao: %f\n", psnr(T, xs));
fprintf("PSNR of phase-corrected VC: %f\n", psnr(Tc, xs));
fprintf("PSNR of modified Wiener: %f\n", psnr(iW, xs));
fprintf("PSNR of modified LM: %f\n", psnr(lm, xs));
fprintf("PSNR of approximate Landweber: %f\n", psnr(dfL, xs));
fprintf("PSNR of modified Richardson-Lucy: %f\n", psnr(mrl, xs));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Show all images
%
figure();
imshow(y);
title('Blurred image');
figure();
imshow(W);
title('Classic Wiener');
figure();
imshow(T);
title('Tao');
figure();
imshow(Tc);
title('pcVC');
figure();
imshow(iW);
title('Modified Wiener');
figure();
imshow(lm);
title('LM');
figure();
imshow(dfL);
title('Approx. Landweber');
figure();
imshow(mrl);
title('Modified RL');