-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain_running.m
99 lines (73 loc) · 2.36 KB
/
main_running.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
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
% This is the main program of MEFB and can be used to produce fused images.
%
% Note: Please change the path in line 24 to your own path before running
%
% If you use this code, please site the following paper:
%
% Zhang, Xingchen. "Benchmarking and comparing multi-exposure image fusion algorithms."
% Information Fusion (2021).
%
% Thanks a lot!
%
% For more information, please see https://github.com/xingchenzhang/MEFB
%
% Contact: xingchen.zhang@imperial.ac.uk
close all
clear
clc
warning off all;
addpath('./util');
addpath(['./methods'])
path = 'Your own path\MEFB\output';
outputPath = [path '\fused_images\'];
imgs = configImgs;
methods=configMethods;
numImgs=length(imgs);
numMethods=length(methods);
if ~exist(outputPath,'dir')
mkdir(outputPath);
end
visualization = 0;
for idxMethod=1:numMethods
m = methods{idxMethod};
t1 = clock;
j =0;
for idxImgs=1:length(imgs)
s = imgs{idxImgs};
sA.img = strcat(s.path,s.name, '_A.',s.ext);
sB.img = strcat(s.path,s.name, '_B.',s.ext);
sA.ext = s.ext;
SB.ext = s.ext;
sA.name = s.name;
sB.name = s.name;
imgA = imread(sA.img);
imgB = imread(sB.img);
[imgH_A,imgW_A,chA] = size(imgA);
[imgH_B,imgW_B,chB] = size(imgB);
% check whether the result exists
if exist([outputPath s.name '_' m.name '.' s.ext])
continue;
end
disp([num2str(idxMethod) '_' m.name ', ' num2str(idxImgs) '_' s.name])
funcName = ['img = run_' m.name '(sA, sB, outputPath, m, visualization);'];
try
cd(['./methods/' m.name]);
addpath(genpath('./'))
eval(funcName);
j=j+1;
catch err
disp('error');
rmpath(genpath('./'))
cd('../../')
continue;
end
imwrite(img, [outputPath '/' s.name '_' m.name '.' s.ext]);
cd('../../');
end
t2=clock;
runtimeAverage = etime(t2,t1)./j;
str=['The total runtime of ' m.name ' is: ' num2str(etime(t2,t1)) 's'];
disp(str)
str=['The average runtime of ' m.name ' per image is: ' num2str(runtimeAverage) 's'];
disp(str)
end