-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLee_EnergyMinimization_Dehazing.m
47 lines (39 loc) · 1.24 KB
/
Lee_EnergyMinimization_Dehazing.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
%% energy minimization dehazing
% I, input image
% J, dehazing result
% T, transmission map
% A, atmospheric color
% Cache, Intermediate data
function [ J, T, A, Cache] = Lee_EnergyMinimization_Dehazing( I )
Cache = cell(3,1);
%% atmospheric color estimate
fprintf('est. atmospheric color...\n');
A = Lee_Get_A(I);
t1=clock;
Iw = Lee_Get_WhiteI(I);
%% solve initial T, alpha-exphansion
fprintf('est. initial transmission map...\n');
tic;
Labels = GraphCut(min(1,max(0,Get_Dx(Iw,1))));
fprintf('Graph cut takes %0.2f second\n',toc);
T_initial = 1-(Labels-1)/31;
%% regularization
fprintf('regularization...\n');
%T_reg=Lee_Regularization(Iw,T_initial,10000,5);
tic;
T_reg=wls_optimization(T_initial,I,0.01);
fprintf('regularization takes %0.2f second\n',toc);
%% brighter
haze_factor = 1.1;
gamma = 1;
T = (T_reg + (haze_factor-1) )/haze_factor;
fprintf('dehazing...\n');
J1 = Lee_Dehaze(Iw,T,[1,1,1]).*repmat(reshape(A,[1,1,3]),size(I,1),size(I,2));
J = J1;
J(J>0)=J(J>0).^gamma;
t2=clock;
runtime = etime(t2,t1);
fprintf('overall run-time is %0.2f second\n',runtime);
%% Intermediate data save
Cache{1} = T_initial;
end