function [sim] = SwayamSimilarity(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
 bins = size(histogram1, 2);
    
    %% estimate the bhattacharyya co-efficient
    
    bcoeff = 0;
    for i=1:bins

        bcoeff = bcoeff + sqrt(histogram1(i) * histogram2(i));

    end
    
    %% get the distance between the two distributions as follows
    
    sim = sqrt(1 - bcoeff);
%sim=bdist;
end
