Determines, using one of two methods, whether a match(es) is present and returns the positions of
       the bottom right corners of the matches.
       Fuzzy matches returns regions, so the center of each region is returned as the final match location

       USE THIS FUNCTION IF you need to match, e.g. the same image but rendered slightly different with respect to
       anti aliasing; the same image on a number of different backgrounds.

       The method is the name of the matching method used, the details of this do not matter. Use the default method
       unless you have too many false positives, in this case, use the method 'correlation coefficient.' The
       correlation coefficient method can also be more robust at matching when the match might not be exact.

       The raw_tolerance is the proportion of the value at match positions (i.e. the value returned for an exact match)
       that we count as a match. For fuzzy matching, this value will not be exactly the value returned for an exact match
       N. B. Lowering raw_tolerance increases the number of potential match tiles requiring normalisation.
       This DRAMATICALLY slows down matching as normalisation (a process which eliminates false positives)

       The normed_tolerance is how far a potential match value can differ from one after normalisation.

       The tolerance values indicated below are from a short investigation, looking to minimise missing items we wish to match,
       as all as false positives which inevitably occur when performing fuzzy matching. To generate these values, we
       tested maching letters with different type of antialiasing on a number of backgrounds.

def fuzzy_match(image, template, normed_tolerance=None, raw_tolerance=None, method='correlation'):
    """Determines, using one of two methods, whether a match(es) is present and returns the positions of
       the bottom right corners of the matches.
       Fuzzy matches returns regions, so the center of each region is returned as the final match location

       USE THIS FUNCTION IF you need to match, e.g. the same image but rendered slightly different with respect to
       anti aliasing; the same image on a number of different backgrounds.

       The method is the name of the matching method used, the details of this do not matter. Use the default method
       unless you have too many false positives, in this case, use the method 'correlation coefficient.' The
       correlation coefficient method can also be more robust at matching when the match might not be exact.

       The raw_tolerance is the proportion of the value at match positions (i.e. the value returned for an exact match)
       that we count as a match. For fuzzy matching, this value will not be exactly the value returned for an exact match
       N. B. Lowering raw_tolerance increases the number of potential match tiles requiring normalisation.
       This DRAMATICALLY slows down matching as normalisation (a process which eliminates false positives)

       The normed_tolerance is how far a potential match value can differ from one after normalisation.

       The tolerance values indicated below are from a short investigation, looking to minimise missing items we wish to match,
       as all as false positives which inevitably occur when performing fuzzy matching. To generate these values, we
       tested maching letters with different type of antialiasing on a number of backgrounds.
    """
    if method == 'correlation':
        if not raw_tolerance:
            raw_tolerance = 0.95
        if not normed_tolerance:
            normed_tolerance = 0.95
        results = np.array(match_via_correlation(image, template, raw_tolerance=raw_tolerance, normed_tolerance=normed_tolerance))
    elif method == 'correlation coefficient':
        if not raw_tolerance:
            raw_tolerance = 0.95
        if not normed_tolerance:
            normed_tolerance = 0.95
        results = np.array(match_via_correlation_coefficient(image, template, raw_tolerance=raw_tolerance, normed_tolerance=normed_tolerance))
    elif method == 'squared difference':
        if not raw_tolerance:
            raw_tolerance = 0.95
        if not normed_tolerance:
            normed_tolerance = 0.05
        results = np.array(match_via_squared_difference(image, template, raw_tolerance=raw_tolerance, sq_diff_tolerance=normed_tolerance))
    h, w = image.shape
    th, tw = template.shape
    results = np.array([(result[0], result[1]) for result in results])
    #match_x, match_y = int(np.mean(results[:,1])), int(np.mean(results[:,0]))
    results_aggregated_mean_match_position = match_positions((h,w), results)
    return results_aggregated_mean_match_position