function [sim] = SwayamSimilarity02(im1, im2)
    %Compares using the Euclidean distance of the images' histograms.
    %This divides by the maximum frequency in the histogram to obtain
    %relative frequencies, rather than an absolute number of pixels.
    %This yields a better average correlation between the histograms.
   % sim = norm((imhist(im1, 256) / max(imhist(im1, 256))) - (imhist(im2, 256) / max(imhist(im2, 256))));
    histogram1=norm(imhist(im1, 256)/ max(imhist(im2, 256)));
    histogram2=norm(imhist(im2, 256) / max(imhist(im2, 256)));
    %sim = norm(imhist(im1) - imhist(im2)); %Old method
chsq = 0;
nbins = size(histogram1,2);
for j=1:nbins
   if (histogram1(j) == 0.0 && histogram2(j) == 0.0)
%sim=0;
   else
       temp=histogram1(j)-histogram2(j);
       chsq = chsq + (temp*temp/(histogram1(j)+histogram2(j))) ;
      % sim = chsq;
   end

end
sim = chsq;
end