def erase_corners(image_array, corner_size=300):
    """
    Fill the corners of the image with the closest pixel value.
    This is useful when a diaphragm is visible in the field of view.

    Parameters
    ----------
    image_array : numpy.ndarray
        The original image.
    corner_size : int, optional
        The size of the corner to fill, by default 300

    Returns
    -------
    numpy.ndarray
        The new image with corners filled.
    """

    if corner_size > 0:
        image_array[..., :corner_size, :corner_size] = image_array[...,
                                                                   corner_size, corner_size, None, None]
        image_array[..., :corner_size, -corner_size:] = image_array[...,
                                                                    corner_size, -corner_size, None, None]
        image_array[..., -corner_size:, -corner_size:] = image_array[..., -
                                                                     corner_size, -corner_size, None, None]
        image_array[..., -corner_size:, :corner_size] = image_array[..., -
                                                                    corner_size, corner_size, None, None]

    return image_array