As above, but for when the correlation coefficient matching method is used

def normalise_correlation_coefficient(image_tile_dict, transformed_array, template, normed_tolerance=1):
    """As above, but for when the correlation coefficient matching method is used
    """
    template_mean = np.mean(template)
    template_minus_mean = template - template_mean
    template_norm = np.linalg.norm(template_minus_mean)
    image_norms = {(x,y):np.linalg.norm(image_tile_dict[(x,y)]- np.mean(image_tile_dict[(x,y)]))*template_norm for (x,y) in image_tile_dict.keys()}
    match_points = image_tile_dict.keys()
    # for correlation, then need to transofrm back to get correct value for division
    h, w = template.shape
    image_matches_normalised = {match_points[i]:transformed_array[match_points[i][0], match_points[i][1]]/image_norms[match_points[i]] for i in range(len(match_points))}
    normalised_matches = {key:value for key, value in image_matches_normalised.items() if np.round(value, decimals=3) >= normed_tolerance}
    return normalised_matches.keys()