Masks¶
The classes implemented in the masks
module define how to retrieve a binary mask of the tissue from a Slide object. This step is necessary during the tiles extraction phase.
The masks
module already implements different approaches to retrieve specific tissue regions within the slide:
the TissueMask class segments the whole tissue area in the slide leveraging a sequence of native filters, including conversion to grayscale, Otsu thresholding, binary dilation, small holes and small objects removal; the BiggestTissueBoxMask class applies the same chain of filters as TissueMask but it returns a binary mask corresponding to the bounding box of the largest connected tissue region within the slide.
Alternatively, a custom binary mask can be defined with the BinaryMask class.
- class BinaryMask[source]¶
Generic object for binary masks.
This object can be used to create a custom binary mask object.
Example
>>> from histolab.slide import Slide >>> class MyCustomMask(BinaryMask): ... def _mask(self, slide): ... my_mask = np.array([0,1]) ... return my_mask >>> binary_mask = MyCustomMask() >>> slide = Slide("path/to/slide") >>> binary_mask(slide)
- class BiggestTissueBoxMask(*filters)[source]¶
Object that represents the box containing the largest contiguous tissue area.
- Parameters
filters (Iterable[histolab.filters.image_filters.Filter]) –
- Return type
None
- __call__(slide)¶
Call self as a function.
- class TissueMask(*filters)[source]¶
Object that represent the whole tissue area mask.
- Parameters
filters (Iterable[histolab.filters.image_filters.Filter]) –
- Return type
None