def split_overlap(base_mask, test_mask, return_segments=False):
    '\n    This function takes all blobs in the base_mask and checks whether they overlap with the test_mask.\n    The function returns two new masks, one mask with all the blobs that overlapped, and another with the blobs\n    that did not overlap.\n    :param base_mask:\n    :param test_mask:\n    :return:\n    '
    overlapping = np.zeros_like(base_mask, dtype=bool)
    not_overlapping = np.copy(base_mask)
    from photutils import detect_sources
    segments = detect_sources(base_mask.astype('float'), 0.5, 1).data
    overlap = intersection(segments, test_mask)
    possible = np.array(range(1, (np.max(overlap) + 1)))
    present = np.in1d(possible, overlap)
    indices = possible[present]
    overlapping_segments = np.zeros_like(base_mask, dtype=int)
    not_overlapping_segments = np.copy(segments)
    for index in indices:
        blob = (segments == index)
        overlapping[blob] = True
        not_overlapping[blob] = False
        overlapping_segments[blob] = index
        not_overlapping_segments[blob] = 0
    if return_segments:
        return (overlapping, not_overlapping, overlapping_segments, not_overlapping_segments)
    else:
        return (overlapping, not_overlapping)
This function takes all blobs in the base_mask and checks whether they overlap with the test_mask.
The function returns two new masks, one mask with all the blobs that overlapped, and another with the blobs
that did not overlap.
:param base_mask:
:param test_mask:
:return:
def split_overlap(base_mask, test_mask, return_segments=False):
    '\n    This function takes all blobs in the base_mask and checks whether they overlap with the test_mask.\n    The function returns two new masks, one mask with all the blobs that overlapped, and another with the blobs\n    that did not overlap.\n    :param base_mask:\n    :param test_mask:\n    :return:\n    '
    overlapping = np.zeros_like(base_mask, dtype=bool)
    not_overlapping = np.copy(base_mask)
    from photutils import detect_sources
    segments = detect_sources(base_mask.astype('float'), 0.5, 1).data
    overlap = intersection(segments, test_mask)
    possible = np.array(range(1, (np.max(overlap) + 1)))
    present = np.in1d(possible, overlap)
    indices = possible[present]
    overlapping_segments = np.zeros_like(base_mask, dtype=int)
    not_overlapping_segments = np.copy(segments)
    for index in indices:
        blob = (segments == index)
        overlapping[blob] = True
        not_overlapping[blob] = False
        overlapping_segments[blob] = index
        not_overlapping_segments[blob] = 0
    if return_segments:
        return (overlapping, not_overlapping, overlapping_segments, not_overlapping_segments)
    else:
        return (overlapping, not_overlapping)