-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemo.m
74 lines (62 loc) · 1.9 KB
/
demo.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
% Code for Illuminant Spectra-based Source Separation Using Flash Photography
% This code is based on the algorithm proposed in the paper
% "Illuminant Spectra-based Source Separation Using Flash Photographye", CVPR 2018
% Zhuo Hui, Kalyan Sunkavalli, Sunil Hadap, Aswin C. Sankaranarayanan
% When you use the code to build your algorithm, please cite this paper.
%
% Please contact the author Zhuo Hui if you have any problems with the code
% huizhuo1987@gmail.com
%
% Copy rights reserved by the authors listed above.
% set up the route
setup()
% load the data to process
disp('Loading data...')
load('data\reflectance_illum_camera.mat')
load('data\images\two_lights\book.mat')
disp('Done.')
% generate basis for both reflectance/illumination
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('Generate basis....')
[UR, UL] = genBase(L, C, R, 'wpca1');
for ind = 1:3
E(:,:,ind) = UR'*diag(C(:, ind))*UL;
end
opt.E = E;
flash_light = .025*ones(size(L(:, 1)));
f = UL'*flash_light;
f = f/norm(f);
opt.f = f;
%% Demo for TWO lights
%% These parameter can be adjusted for better performance
opt.lambda = 1e-5;
opt.cutoff = .1;
opt.color_correct = 1;
opt.light_number = 2;
opt.shadow_mask = 1 - mask;
disp('Done.')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
%
disp('Processing the data....')
results = solve_light_sep(im_nf, im_f, mask, opt);
disp('Done');
%% Visulize the results
imshow([results.im1 results.im2].^(1/2.2))
%% Demo for Three lights
%% These parameter can be adjusted for better performance
disp('Loading data...')
load('data\images\three_lights\toy.mat')
disp('Done.')
opt.lambda = 1e-5;
opt.cutoff = .1;
opt.color_correct = 1;
opt.light_number = 3;
opt.shadow_mask = shadow_mask;
disp('Done.')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
%
disp('Processing the data....')
results = solve_light_sep(im_nf, im_f, mask, opt);
disp('Done');
%% Visulize the results
imshow([results.im1 results.im2].^(1/2.2))