def make_uniform(planes_dict, uniques, padding):
    """ Ensure each section has the same number of images

    This function makes the output collection uniform in
    the sense that it preserves same number of planes across 
    sections. It also captures additional planes based
    on the value of the padding variable

    Args:
        planes_dict (dict): planes to keep in different sections
        uniques (list): unique values for the major grouping variable
        padding (int): additional images to capture outside cutoff

    Returns:
        dictionary: dictionary containing planes to keep
    """

    # max no. of planes 
    max_len = max([len(i) for i in planes_dict.values()])

    # max planes that can be added on each side
    min_ind = min([min(planes_dict[k]) for k in planes_dict])
    max_ind = max([max(planes_dict[k]) for k in planes_dict])
    max_add_left = uniques.index(min_ind)
    max_add_right = len(uniques) - (uniques.index(max_ind)+1)
    
    # add planes in each section based on padding and max number of planes
    for section_id, planes in planes_dict.items():
        len_to_add = max_len - len(planes)
        len_add_left = min(int(len_to_add)/2+padding, max_add_left)
        len_add_right = min(len_to_add - len_add_left+padding, max_add_right)
        left_ind = int(uniques.index(min(planes)) - len_add_left) 
        right_ind = int(uniques.index(max(planes)) + len_add_right)+1
        planes_dict[section_id] = uniques[left_ind:right_ind]
    return planes_dict