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[source]¶
Object that represents the box containing the largest contiguous tissue area.
Internally, this class automatically detects the tissue regions via a predefined sequence of filters, and then retain the largest connected component.
- __call__(slide)¶
Call self as a function.
- class TissueMask[source]¶
Object that represent the whole tissue area mask.
The tissue within the slide or tile is automatically detected through a predefined chain of filters.