-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfTestImageLRTV2D.m
More file actions
59 lines (51 loc) · 2.11 KB
/
Copy pathfTestImageLRTV2D.m
File metadata and controls
59 lines (51 loc) · 2.11 KB
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
function [fTV, errList_H] = fTestImageLRTV2D(ylr,rate,f0,para)
% read a 2D image and produce out a 2D result.
% input: LR image, scale factor, the HR ground truth image
% output: HR image
% test the Image Deconvolution using Variational Method
% para is for parameters with a struct format, test exist: isfield(para,'t')
%%
% addpath mylib
% disp(para);
if nargin > 3
if isfield(para,'rho') > 0 ; rho = para.rho; else rho = 0.1; end
if isfield(para,'dt') > 0 ; dt = para.dt; else dt = 0.1; end
if isfield(para,'epsilon') > 0 ; epsilon = para.epsilon; else epsilon = 1e-5; end
if isfield(para,'lambdaTV') > 0 ; lambdaTV = para.lambdaTV; else lambdaTV = 0.01; end
if isfield(para,'lambdaRank') > 0 ; lambdaRank = para.lambdaRank; else lambdaRank = 0.01; end
if isfield(para,'niter') > 0 ; niter = para.niter; else niter = 20; end
if isfield(para,'n') > 0 ; n = para.n; else n = 256; end
end
s = 1;
x = [0:n/2-1, -n/2:-1];
[Y,X] = meshgrid(x,x);
h = exp( (-X.^2-Y.^2)/(2*s^2) );
h = h/sum(h(:));
% Phi = @(x,h)real(ifft2(fft2(x).*fft2(h)));
% rho = 0.1;
% dt = 0.1;
% epsilon = 1e-5;
% lambdaTV = 0.01;
% lambdaRank = 0.01;
% niter = 2; %20; % use 5 for fast testing.
alpha = [1, 1];
alpha = alpha / sum(alpha);
if nargin <3 % f0 is not inputed
f0 = my_upsample(ylr,rate);
f0 = f0(1:size(h,1),1:size(h,2));
end
%% High Accuracy LRTC (solve the original problem, HaLRTC algorithm in the paper)
[fTV, errList_H] = myHaLRTC_backup(...
ylr, ... % a tensor whose elements in Omega are used for estimating missing value
h, ... % kenerl
rate, ... % rate
alpha, ... % the coefficient of the objective function, i.e., \|X\|_* := \alpha_i \|X_{i(i)}\|_*
lambdaTV, ... % for TV
lambdaRank, ... % for low rank
rho,... % the initial value of the parameter; it should be small enough
niter,... % the maximum iterations
dt,... % for tv
epsilon, ... % the tolerance of the relative difference of outputs of two neighbor iterations
f0 ... % ground truth
);
% disp(snr(f0,fTV));