def put_image_in_centre_of_other_image(img1, img2, add=False):
    """
    Code to add a mask to the centre of a given image (both 2D at the moment)
    :param img1: image to be putting other image in the centre of
    :param img2: image to put in the centre of another image
    :param add: flag as to whether to add the image to the centre of the other one or replace all pixels
    :return: Final image with img2 now in the centre of img1
    """

    borderx_size = (img1.shape[1] - img2.shape[1])/2
    bordery_size = (img1.shape[0] - img2.shape[0])/ 2

    x1 = int(borderx_size)
    x2 = int(borderx_size + img2.shape[1])
    y1 = int(bordery_size)
    y2 = int(bordery_size + img2.shape[0])

    new_img = img1.copy()
    if add:
        new_img[y1:y2, x1:x2] += img2
    else:
        new_img[y1:y2, x1:x2] = img2

    return new_img