skimage2.segmentation.join_segmentations#

skimage2.segmentation.join_segmentations(s1, s2, return_mapping: bool = False)[source]#

Return the join of the two input segmentations.

The join J of S1 and S2 is defined as the segmentation in which two voxels are in the same segment if and only if they are in the same segment in both S1 and S2.

Parameters:
s1, s2numpy arrays

s1 and s2 are label fields of the same shape.

return_mappingbool, optional

If true, return mappings for joined segmentation labels to the original labels.

Returns:
jnumpy array

The join segmentation of s1 and s2.

map_j_to_s1ArrayMap, optional

Mapping from labels of the joined segmentation j to labels of s1.

map_j_to_s2ArrayMap, optional

Mapping from labels of the joined segmentation j to labels of s2.

Examples

>>> from _skimage2.segmentation import join_segmentations
>>> s1 = np.array([[0, 0, 1, 1],
...                [0, 2, 1, 1],
...                [2, 2, 2, 1]])
>>> s2 = np.array([[0, 1, 1, 0],
...                [0, 1, 1, 0],
...                [0, 1, 1, 1]])
>>> join_segmentations(s1, s2)
array([[0, 1, 3, 2],
       [0, 5, 3, 2],
       [4, 5, 5, 3]])
>>> j, m1, m2 = join_segmentations(s1, s2, return_mapping=True)
>>> m1
ArrayMap(array([0, 1, 2, 3, 4, 5]), array([0, 0, 1, 1, 2, 2]))
>>> np.all(m1[j] == s1)
True
>>> np.all(m2[j] == s2)
True