fatf.utils.data.segmentation.get_segment_mask

fatf.utils.data.segmentation.get_segment_mask(segments_subset: Union[int, List[int]], segmentation: numpy.ndarray) → numpy.ndarray[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.

Parameters
segments_subsetintiger or list(integer)

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

segmentationnp.ndarray

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).

Returns
segment_masknumpy.ndarray

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

Raises
IncorrectShapeError

The segmentation array is not 2-dimensional.

TypeError

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.

ValueError

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.