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.

This object can be used to create a custom binary mask object.

Example

>>> from histolab.slide import Slide
>>> slide = Slide("path/to/slide")

__call__(slide)[source]

Call self as a function.

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.

Object that represent the whole tissue area mask.

Parameters

filters (Iterable[histolab.filters.image_filters.Filter]) –

Return type

None

__call__(obj)[source]

Apply a predefined chain of filters to calculate the tissue area mask.

The applied filters will be different based on the type of obj, please see

filters.compositions.FiltersComposition

Parameters

obj (Union[Slide, Tile]) – Slide or Tile from which to compute the extraction mask.

Returns

Binary mask of the tissue area. The dimensions are those of the thumbnail in case obj is a Slide, otherwise they are the same as the tile.

Return type

np.ndarray