-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.m
More file actions
executable file
·51 lines (43 loc) · 993 Bytes
/
example.m
File metadata and controls
executable file
·51 lines (43 loc) · 993 Bytes
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
% test the Image Deconvolution using Variational Method
% function fTestImageLRTV
%%
clear;clc;
addpath mylib
n = 256;
% name = 'lena';
name = 'xch2';
f0 = load_image(name);
if ndims(f0) > 2 ; f0 = f0(:,:,1); end;
if min(size(f0)) >= n
f0 = rescale(crop(f0,n));
else
img = zeros(n,n);
img(1:size(f0,1),1:size(f0,2)) = f0;
f0=img;
clear img;
end
org=f0;
rate = 2;
%% preprocessing
s = 1;
n=size(f0,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)));
y0 = Phi(f0,h);
ylr = my_downsample(y0,rate);
figure(1);imshow(ylr,[]);
g = my_upsample(ylr,rate);
g=g(1:size(y0,1),1:size(y0,2));
figure(2);imshow(g,[]);
snr(f0,g)
figure(3);imshow(f0,[]);
% input is original and output is larger
%% image recover
para.niter = 6;
para.dt = 0.1;
[fTV, errList_H] = fTestImageLRTV2D(ylr,rate,f0,para);
snr(f0,fTV)
figure(4);imshow(fTV,[]);