-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemo_PN.m
38 lines (36 loc) · 1.36 KB
/
demo_PN.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
% This code is the implementation of Post Normalization algorithm in paper
% "Normalized Blind Deconvolution" ECCV 2018
clear
addpath('lib/');
addpath('PN/');
%% -----------------------------------------------------------------------%
% Input %
% ------------------------------------------------------------------------%
g = imread('levin_input.png');
%% -----------------------------------------------------------------------%
% Parameters %
% ------------------------------------------------------------------------%
% kernel size
MK = 31;
NK = 31;
% regularization parameter. It is not tuned.
lambda = 0.008;
% Lp norm
params.P = 2;
params.gammaCorrection = false;
params.gamma = 0;
% number of iterations in each pyramid level
params.iters = 800;
params.visualize = 1;
% increase kernel size at each pyramid level, the larger, the fewer level
params.kernelSizeMultiplier = 1.2;
%% -----------------------------------------------------------------------%
% Deblur %
% ------------------------------------------------------------------------%
tic
[u, k] = deblur(g,MK,NK,lambda, params);
toc
u(u<0) = 0;
u(u>1) = 1;
imwrite(u,'out.png');
imwrite(imresize(k./max(k(:)),5,'nearest'),'kernel.png');