import math


def calc_overlap(params):
    """
    Function to calculate the number of pixels requires in overlap, based on chunk_size and overlap percentage,
    if provided in the config file
    :param params: (dict) Parameters found in the yaml config file.
    :return: (int) number of pixel required for overlap
    """
    chunk_size = 512
    overlap = 10

    if params['inference']['chunk_size']:
        chunk_size = int(params['inference']['chunk_size'])
    if params['inference']['overlap']:
        overlap = int(params['inference']['overlap'])
    nbr_pix_overlap = int(math.floor(overlap / 100 * chunk_size))
    return chunk_size, nbr_pix_overlap