def undo_pad(data, pad_size):
    """Remove padding fromt edges of images

    Parameters
    ----------
    data : array-like
        padded image

    pad_size : array-like
            amount of padding in every direction of the image

    Returns
    -------
    data : array-like
        unpadded image

    """
    if pad_size.ndim == 1 and data.ndim != 1:
        raise ValueError("Dimensions do not match")

    if data.ndim != pad_size.shape[0]:
        raise ValueError("Dimensions do not match")

    start = pad_size[:, 0].astype(int)
    end = (data.shape - pad_size[:, 1]).astype(int)
    coords = list(zip(start, end))
    slices = tuple(slice(coord[0], coord[1]) for coord in coords)
    data = data[slices]

    return data