% EE368/CS232 Digital Image Processing
% Bernd Girod
% Department of Electrical Engineering, Stanford University 

% Script by Qiyuan Tian and David Chen
% High dynamic range imaging

% Exposure Fusion scripts downloaded from:
% http://research.edm.uhasselt.be/~tmertens/exposure_fusion/

clear, clc, close all

% Load source images
I = load_images('stlouis_high');

% Show source images
figure(1), clf;
subplot(2,2,1); imshow(I(:,:,:,1)); title('Input Image 1');
subplot(2,2,2); imshow(I(:,:,:,2)); title('Input Image 2');
subplot(2,2,3); imshow(I(:,:,:,3)); title('Input Image 3');
subplot(2,2,4); imshow(I(:,:,:,4)); title('Input Image 4');

% Perform fusion and show result
blendedImg = exposure_fusion(I,[1 1 1]);
figure(2), clf;
imshow(blendedImg); title('Combined Image');
imwrite(blendedImg, 'HDR_combined.png');
