function [V]=SSGSM(I)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% I: input image
%
% Author: Joshin John Mathew & Alex Pappachen James
% Date: 21-01-2015
%
% Citations:
% J.J. Mathew,A.P. James, "Spatial Stimuli Gradient Sketch Model", IEEE Signal Processing Letters, 2015
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Logarithm of input image, constant k is taken as '1'
I=log(I);
% Removes undesired numerical errors
[I]=RemoveNanAndInf(I);
% Gradient operation
[gx,gy]=gradient(I);
% Local change in brightness along 'x' axis
Vx=gx.*exp(-(abs(gx)));
% Vx=abs(gx).*(1-exp((-abs(gx)))); %for high noise suppression
% Local change in brightness along 'y' axis
Vy=gy.*exp(-(abs(gy)));
% Vy=abs(gy).*(1-exp((-abs(gy)))); %for high noise suppression
% Local stimuli map
V=sqrt(Vx.^2+Vy.^2);
end
function [I]=RemoveNanAndInf(I)
% Replaces 'NaN' by '0'
I(find(isnan(I)==1))=0;
% Replaces 'inf' by '0'
I(find(isinf(I)==1))=0;
end