:py:mod:`wsinfer.patchlib.segment` ================================== .. py:module:: wsinfer.patchlib.segment .. autoapi-nested-parse:: Segment thumbnail of a whole slide image. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: wsinfer.patchlib.segment.segment_tissue .. py:function:: 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_] Create a binary tissue mask from an image. :param im_arr: RGB image array (uint8) with shape (rows, cols, 3). :type im_arr: array-like :param median_filter_size: The kernel size for median filtering. Must be odd and greater than one. :type median_filter_size: int :param binary_threshold: The pixel threshold for image binarization. :type binary_threshold: int :param closing_kernel_size: The kernel size for morphological closing (in pixel units). :type closing_kernel_size: int :param min_object_size_px: The minimum area of an object in pixels. If an object is smaller than this area, it is removed and is made into background. :type min_object_size_px: int :param min_hole_size_px: The minimum area of a hole in pixels. If a hole is smaller than this area, it is filled and is made into foreground. :type min_hole_size_px: int :returns: Boolean array, where True values indicate presence of tissue. :rtype: mask