-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplineSRInterp.m
47 lines (34 loc) · 1.38 KB
/
SplineSRInterp.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
% Implements a simple cubic-spline interpolation of a single image. This
% image is then deblured using the same method as in the Fast and Robust
% method.
%
% Inputs:
% LR - A sequence of low resolution images
% resFactor - The resolution increment factor
% Hpsf - The PSF function (common to all frames and space invariant)
% props - property structure used to control the algorithm parameters
%
% Outpus:
% The estimated HR image
function HR=SplineSRInterp(LR, resFactor, Hpsf, props)
% Initialize guess as interpolated version of LR
[X,Y]=meshgrid(0:resFactor:(size(LR,2)-1)*resFactor, 0:resFactor:(size(LR,1)-1)*resFactor);
[XI,YI]=meshgrid(resFactor+1:(size(LR,2)-2)*resFactor-1, resFactor+1:(size(LR,1)-2)*resFactor-1);
Z=interp2(X, Y, squeeze(LR(:,:,1)), XI, YI, '*spline');
% Deblur the HR image and regulate using bilatural filter
% Loop and improve HR in steepest descent direction
HR = Z;
iter = 1;
A = ones(size(HR));
h=waitbar(0, 'Estimating high-resolution image');
while iter<props.maxIter
waitbar(iter/props.maxIter);
% Compute gradient of the energy part of the cost function
Gback = FastGradientBackProject(HR, Z, A, Hpsf);
% Compute the gradient of the bilateral filter part of the cost function
Greg = GradientRegulization(HR, props.P, props.alpha);
% Perform a single SD step
HR = HR - props.beta.*(Gback + props.lambda.* Greg);
iter=iter+1;
end
close(h);