def compare_entropy(name_img1,name_img2,method="<STR_LIT>"):
img1 = mpimg.imread(name_img1)<EOL>img2 = mpimg.imread(name_img2)<EOL>fimg1 = img1.flatten()<EOL>fimg2 = img2.flatten()<EOL>if method == "<STR_LIT>":<EOL><INDENT>eps = <NUM_LIT><EOL>S = stats.entropy(fimg2+eps,fimg1+eps)<EOL>S = numpy.log10(S)<EOL><DEDENT>elif method == "<STR_LIT>":<EOL><INDENT>fdiff=fimg1-fimg2<EOL>fdiff_sqr = fdiff**<NUM_LIT:4><EOL>S = (fdiff_sqr.sum())**(old_div(<NUM_LIT:1.>,<NUM_LIT:4>))<EOL><DEDENT>return S,fimg1, fimg2<EOL>
Compare two images by the Kullback-Leibler divergence

    Parameters
    ----------
    name_img1 : string
      filename of image 1 (png format)

    name_img2 : string
      filename of image 2 (png format)

    Returns
    -------
    S : float
       Kullback-Leibler divergence S = sum(pk * log(pk / qk), axis=0)

    Note
    ----
    See http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.entropy.html