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
Truewhere 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
segmentationindicating the pixels (True) belonging to the specified segments.
- Raises
- IncorrectShapeError
The
segmentationarray is not 2-dimensional.- TypeError
The
segments_subsetparameter is neither an integer nor a list of integers; one of the segment ids in this list is not an integer. Thesegmentationarray is either a structured numpy array or it is not an integer-valued array.- ValueError
One of the segment ids provided via
segments_subsetis invalid for thesegmentationor some of its elements are duplicated. The unique elements of thesegmentsarray do not form a continuous sequence starting at 1.