wsinfer.patchlib.segment#

Segment thumbnail of a whole slide image.

Functions#

segment_tissue(→ numpy.typing.NDArray[numpy.bool_])

Create a binary tissue mask from an image.

Module Contents#

wsinfer.patchlib.segment.segment_tissue(im_arr: numpy.typing.NDArray, median_filter_size: int = 7, binary_threshold: int = 7, closing_kernel_size: int = 6, min_object_size_px: int = 512, min_hole_size_px: int = 1024) numpy.typing.NDArray[numpy.bool_][source]#

Create a binary tissue mask from an image.

Parameters:
  • im_arr (array-like) – RGB image array (uint8) with shape (rows, cols, 3).

  • median_filter_size (int) – The kernel size for median filtering. Must be odd and greater than one.

  • binary_threshold (int) – The pixel threshold for image binarization.

  • closing_kernel_size (int) – The kernel size for morphological closing (in pixel units).

  • min_object_size_px (int) – The minimum area of an object in pixels. If an object is smaller than this area, it is removed and is made into background.

  • min_hole_size_px (int) – The minimum area of a hole in pixels. If a hole is smaller than this area, it is filled and is made into foreground.

Returns:

Boolean array, where True values indicate presence of tissue.

Return type:

mask