% Copyright (c) 2017 Indian Institute of Science, Bangalore, India.
% All rights reserved.
% 
% Permission to use, copy, or modify this software and its documentation
% for educational and research purposes only and without fee is
% hereby granted, provided that this copyright notice and the original 
% authors' names appear on all copies and supporting documentation.
% This program shall not be used, rewritten, or adapted as the basis
% of a commercial software or hardware product without first obtaining
% permission of the authors. The authors make no representations about the
% suitability of this software for any purpose. It is provided "as is"
% without express or implied warranty.
% 
% The following papers are to be cited in the bibliography whenever
% the software is used as:
% Hisham Rahman, Rajiv Soundararajan, and R. Venkatesh Babu,
% "Evaluating Multiexposure Fusion Using Image Information",
% Signal Processing Letters, in print, DOI: 10.1109/LSP.2017.2752233.
% 
% The attached code computes a single quality score given a test image
% and set of over/under-exposed reference images.
% 
% For questions and/or comments please email
% Hisham Rahman (hishamrahman@gmail.com).
%
% imgTest: HxW Gray-scale image in double-precision[0,255]
% imgRef: HxWxN Gray-scale over/under-exposed images in double-prec [0,255]

img = imread('Balloons/Fused/Balloons_lsaverage.png');
imgTest = 255*im2double(rgb2gray(img));

[H, W] = size(imgTest);
refImgList = dir('Balloons/Source/*.png');
[totRefImg,~] = size(refImgList);
imgRef = zeros(H, W, totRefImg);
for i=1:totRefImg
    img = imread(strcat('Balloons/Source/', refImgList(i).name)); 
    imgRef(:, :, i) = rgb2gray(img);
end

qScore = mef_qa_imgInfo(imgTest, imgRef);

