-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimsuper_full.m
More file actions
125 lines (110 loc) · 4.95 KB
/
imsuper_full.m
File metadata and controls
125 lines (110 loc) · 4.95 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
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
116
117
118
119
120
121
122
123
124
125
function [im_result im_color] = imsuper_full(imageFilenames, scaleFactor, registration, reconstruction)
if(~exist('registration','var'))
registration = 'vandewalle';
end
if(~exist('reconstruction','var'))
reconstruction = 'interpolation';
end
%% load images
IMAGESNUMBER = length(imageFilenames);
IMAGES = {};
IMAGESINFO = {};
IMAGES{1} = imread(imageFilenames{1});
IMAGESINFO{1} = imfinfo(imageFilenames{1});
for i=2:IMAGESNUMBER
tempImage = imread(imageFilenames{i});
tempInfo = imfinfo(imageFilenames{i});
% check for size mismatch
if not(size(IMAGES{1}) == size(tempImage))
error(['Image ' IMAGESSTRING{i} ' has not the same size as image ' IMAGESSTRING{1}], 'Size error');
return;
elseif not(IMAGESINFO{1}.BitDepth == tempInfo.BitDepth)
error(['Image ' IMAGESSTRING{i} ' is not the same type as image ' IMAGESSTRING{1}], 'Size error');
return;
else
IMAGES{i} = tempImage;
IMAGESINFO{i} = tempInfo;
end
end
%%% preprocessing images
for i=1:IMAGESNUMBER
im{i} = IMAGES{i};
im{i} = im2double(im{i}); %double(im{i})/(2^(IMAGESINFO{i}.BitDepth/3));
imColor{i} = im{i};
if (size(size(IMAGES{1}), 2) == 3)
im{i} = rgb2gray(im{i});
end
end
%% registration
switch registration
case 'vandewalle'
[delta_est, phi_est] = estimate_motion(im,0.6,25);
case 'marcel'
[delta_est, phi_est] = marcel(im,2);
case 'lucchese'
[delta_est, phi_est] = lucchese(im,2);
case 'keren'
[delta_est, phi_est] = keren(im);
otherwise
[delta_est, phi_est] = estimate_motion(im,0.6,25);
end
%% signal reconstruction
if (size(size(IMAGES{1}), 2) == 3)
for i=1:IMAGESNUMBER
im_R{i} = imColor{i}(:,:,1);
im_G{i} = imColor{i}(:,:,2);
im_B{i} = imColor{i}(:,:,3);
end
switch reconstruction
case 'interpolation'
im_result = interpolation(im_R,delta_est,phi_est,scaleFactor);
im_result(:,:,2) = interpolation(im_G,delta_est,phi_est,scaleFactor);
im_result(:,:,3) = interpolation(im_B,delta_est,phi_est,scaleFactor);
case 'papoulis-gerchberg'
im_result = papoulisgerchberg(im_R,delta_est,scaleFactor);
im_result(:,:,2) = papoulisgerchberg(im_G,delta_est,scaleFactor);
im_result(:,:,3) = papoulisgerchberg(im_B,delta_est,scaleFactor);
case 'iteratedBP'
im_result = iteratedbackprojection(im_R, delta_est, phi_est, scaleFactor);
im_result(:,:,2) = iteratedbackprojection(im_G, delta_est, phi_est, scaleFactor);
im_result(:,:,3) = iteratedbackprojection(im_B, delta_est, phi_est, scaleFactor);
case 'robustSR'
im_result = robustSR(im_R, delta_est, phi_est, scaleFactor);
im_result(:,:,2) = robustSR(im_G, delta_est, phi_est, scaleFactor);
im_result(:,:,3) = robustSR(im_B, delta_est, phi_est, scaleFactor);
case 'pocs'
im_result = pocs(im_R,delta_est,scaleFactor);
im_result(:,:,2) = pocs(im_G,delta_est,scaleFactor);
im_result(:,:,3) = pocs(im_B,delta_est,scaleFactor);
case 'normConv'
correctNoise = false;
twoPass = false;
im_result = n_conv(im_R,delta_est,phi_est,scaleFactor,correctNoise,twoPass);%Last two parameters are booleans for: noiseCorrect and TwoPass
im_result(:,:,2) = n_conv(im_G,delta_est,phi_est,scaleFactor,correctNoise,twoPass);%Last two parameters are booleans for: noiseCorrect and TwoPass
im_result(:,:,3) = n_conv(im_B,delta_est,phi_est,scaleFactor,correctNoise,twoPass);%Last two parameters are booleans for: noiseCorrect and TwoPass
otherwise
im_result = interpolation(im_R,delta_est,phi_est,scaleFactor);
im_result(:,:,2) = interpolation(im_G,delta_est,phi_est,scaleFactor);
im_result(:,:,3) = interpolation(im_B,delta_est,phi_est,scaleFactor);
end
else
switch reconstruction
case 'interpolation'
im_result = interpolation(im,delta_est,phi_est,scaleFactor);
case 'papoulis-gerchberg'
im_result = papoulisgerchberg(im,delta_est,scaleFactor);
case 'iteratedBP'
im_result = iteratedbackprojection(im, delta_est, phi_est, scaleFactor);
case 'robustSR'
im_result = robustSR(im, delta_est, phi_est, scaleFactor);
case 'pocs'
im_result = pocs(im,delta_est,scaleFactor);
case 'normConv'
correctNoise = false;
twoPass = false;
im_result = n_conv(im,delta_est,phi_est,scaleFactor,correctNoise,twoPass);%Last two parameters are booleans for: noiseCorrect and TwoPass
otherwise
im_result = interpolation(im,delta_est,phi_est,scaleFactor);
end
end
im_color = im_result;