# Path: bot/common.py
# def mse(image_a, image_b):
#     # the 'Mean Squared Error' between the two images is the
#     # sum of the squared difference between the two images;
#     # NOTE: the two images must have the same dimension
#     err = np.sum((image_a.astype("float") - image_b.astype("float")) ** 2)
#     err /= float(image_a.shape[0] * image_a.shape[1])
# 
#     # return the MSE, the lower the error, the more "similar"
#     # the two images are
#     return err


import matplotlib.pyplot as plt
from skimage.measure import compare_ssim
from bot.common import mse

def compare_images(image_a, image_b, title):
    # compute the mean squared error and structural similarity
    # index for the images
    m = mse(image_a, image_b)
    s = compare_ssim(image_a, image_b, multichannel=True)

    # setup the figure
    fig = plt.figure(title)
    plt.suptitle("MSE: %.2f, SSIM: %.2f" % (m, s))

    # show first image
    ax = fig.add_subplot(1, 2, 1)

# Path: bot/common.py
# def mse(image_a, image_b):
#     # the 'Mean Squared Error' between the two images is the
#     # sum of the squared difference between the two images;
#     # NOTE: the two images must have the same dimension
#     err = np.sum((image_a.astype("float") - image_b.astype("float")) ** 2)
#     err /= float(image_a.shape[0] * image_a.shape[1])
# 
#     # return the MSE, the lower the error, the more "similar"
#     # the two images are
#     return err


# Path: bot/debug_helpers/image_compare.py
import matplotlib.pyplot as plt
from skimage.measure import compare_ssim
from bot.common import mse


def compare_images(image_a, image_b, title):
    # compute the mean squared error and structural similarity
    # index for the images
    m = mse(image_a, image_b)
    s = compare_ssim(image_a, image_b, multichannel=True)

    # setup the figure
    fig = plt.figure(title)
    plt.suptitle("MSE: %.2f, SSIM: %.2f" % (m, s))

    # show first image
    ax = fig.add_subplot(1, 2, 1)

    plt.imshow(image_a, cmap=plt.cm.gray)