def compute_relative_overlaps(volumes_1, volumes_2, overlap):
    """Compute the relative overlap between each region labelled mask.

    Arguments
    ---------
    volumes_1 : np.ndarray(dtype=int, shape=(num_labels_1,))
        Size of each mask in the first region-labelled image
    volumes_2 : np.ndarray(dtype=int, shape=(num_labels_2,))
        Size of each mask in the second region-labelled image
    overlap : np.ndarray(dtype=int, shape=(num_labels_1, num_labels_2))
        Matrix with overlap between each labels of the two masks.
        Returned by `compute_pairwise_overlaps`.

    Returns
    -------
    relative_overlap_1 : np.ndarray(dtype=float, shape=(num_labels_1, num_labels_2))
    relative_overlap_2 : np.ndarray(dtype=float, shape=(num_labels_1, num_labels_2))
    """
    return (overlap / volumes_1.reshape(-1, 1), overlap / volumes_2.reshape(1, -1))