function [disto_Val, PGD_Unnormalized_Val, SLR_Unnormalized_Val, Weight_for_PGD]=calDistortion(inFile, refFile, salFile)
% Input inFile: input file name. usually is retargeted image or degraded image.
% refFile: Reference image filename (Ground truth)
% salFile: Saliency map path (set to empty to autmoatically calculate. Default method: Fang's saliency detection method)
% Output: disto_val: disto_vale obtained PGD and SLR with adative weight.
% PGD_Unnormalized_Val: PGD value. The higher PGD, the higher geometric distortion
% SLR_Unnormalized_Val: SLR value. The higher SLR, the higher information loss ratio.
% Weight_for_PGD: The adaptive weight for PGD. 



% Parameters for our own database
Image_Settings;

sal1 = [];
if (para.usedSaliencyType==3), sal1 = salFile; end

% compute the score for algorithms
n1 = [];

% compute the score for algorithms
% Spatial_score: The PGD value
% energy_score_warp: The SLR value

[PGD_Unnormalized_Val type1_res_img po1] = spatial_score(refFile, inFile, n1, sal1, para);

[SLR_Unnormalized_Val, map1,~,re1] = energy_score_warp(refFile, inFile, n1, sal1, para);


% Adaptive weight
w = calWeight(map1, 5, 270, 10);
Weight_for_PGD = 1-w;
disto_Val = PGD_Unnormalized_Val*Weight_for_PGD+ SLR_Unnormalized_Val*w;