-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreconstructSkyFromFullModel.m
46 lines (39 loc) · 1.77 KB
/
reconstructSkyFromFullModel.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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% function reconstructedImg = reconstructSkyFromFullModel(imgDims, params, vh, f, phiCam, thetaSun, phiSun)
% Synthesizes the sky according to the input parameters.
%
% Input parameters:
% - imgDims: dimensions of the output image [height width nbChannels]
% - params: the weather coefficients (6xnbChannels, rows = a,b,c,d,e,k)
% - vh: horizon line (where 0 = center of the image, pointing up)
% - f: focal length of the camera
% - phiCam: camera azimuth angle
% - thetaSun: sun zenith angle
% - phiSun: sun azimuth angle
%
% Output parameters:
% - reconstructedImg: rendered sky (in the xyY color space)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function reconstructedImg = reconstructSkyFromFullModel(imgDims, params, f, thetaCam, phiCam, thetaSun, phiSun)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2006-2009 Jean-Francois Lalonde
% Carnegie Mellon University
% Do not distribute
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
imgHeight = imgDims(1);
imgWidth = imgDims(2);
nbChannels = imgDims(3);
[uRange, vRange] = meshgrid(1:imgWidth, 1:imgHeight);
upVec = (uRange - imgWidth/2) - 0.5;
vpVec = (imgHeight/2 - vRange) + 0.5;
% vhImg = floor(imgHeight/2 - vh + 0.5);
% synthesize each channel
reconstructedImg = zeros(imgHeight, imgWidth, nbChannels);
for ch = 1:nbChannels
reconstructedImg(:,:,ch) = exactSkyModelRatio(params(1,ch), params(2,ch), params(3,ch), params(4,ch), params(5,ch), ...
f, upVec, vpVec, params(6,ch), thetaCam, phiCam, phiSun, thetaSun);
end
vhImg = floor(imgHeight/2 - tan(thetaSun-pi/2).*f+0.5);
% black out what's below the horizon
reconstructedImg(vhImg:end,:,:) = 0;