function saliencyMap=SpectralResidual(inImg)

% Read image from file 
% inImg = im2double(rgb2gray(imread('Data/Test/Image/18.bmp')));
SizeImg = size(inImg);
inImg = imresize(inImg, [64 64], 'bicubic');

% Spectral Residual
myFFT = fft2(inImg); 
myLogAmplitude = log(abs(myFFT));
myPhase = angle(myFFT);
mySpectralResidual = myLogAmplitude - imfilter(myLogAmplitude, fspecial('average', 3), 'replicate'); 
saliencyMap = abs(ifft2(exp(mySpectralResidual + 1i*myPhase))).^2; 

% After Effect
saliencyMap = imfilter(saliencyMap, fspecial('disk', 3));
saliencyMap = imresize(saliencyMap, SizeImg, 'bicubic');
saliencyMap = mat2gray(saliencyMap);
% figure();imshow(saliencyMap);

% imwrite(uint8(saliencyMap*255),'Data/Test/SRsaliencyMap.bmp','BMP');