fatf.utils.data.segmentation.get_segment_mask(segments_subset, segmentation)[source]

Generates a boolean mask for pixels belonging to the specified segments.

New in version 0.1.1.

The mask holds True where the pixel belongs to one of the specified segments.

segments_subsetintiger or list(integer)

A number of a specific segment or a list of segments for which a mask will be created.


A 2-dimensional numpy array defining segmentation of an image (each unique integer – in sequence starting at 1 – indicates segment id of the pixel at this coordinate).


A boolean numpy array of the same shape as segmentation indicating the pixels (True) belonging to the specified segments.


The segmentation array is not 2-dimensional.


The segments_subset parameter is neither an integer nor a list of integers; one of the segment ids in this list is not an integer. The segmentation array is either a structured numpy array or it is not an integer-valued array.


One of the segment ids provided via segments_subset is invalid for the segmentation or some of its elements are duplicated. The unique elements of the segments array do not form a continuous sequence starting at 1.