wsipipe.preprocess.tissue_detection package

tissue_detector module

Tissue Detectors create a 2d array of booleans indicating if that area contains tissue or not.

The input is an RGB numpy array representing the slide. Usually a downsampled thumbnail image as whole slide images as level 0 are often too large to store in memory.

class TissueDetector(pre_filter=<wsipipe.preprocess.tissue_detection.filters.NullBlur object>, morph_transform=<wsipipe.preprocess.tissue_detection.morphology_transforms.NullTransform object>)[source]

Bases: object

Generic tissue detector class

Parameters:
  • pre_filter (Union[PreFilter, List[PreFilter]]) – Any filters or transforms that are to be applied before the tissue detection. Can be lists of filters or individual filters. Defaults to NullBlur

  • () (morph_transform) – Any filters or transforms that are to be applied after the tissue detection. Can be lists of transforms or individual transforms. Defaults to NullTransform

  • morph_transform (Union[MorphologyTransform, List[MorphologyTransform]]) –

Returns:

An ndarray of booleans with the same dimensions as the input image True means foreground, False means background

class TissueDetectorAll(pre_filter=<wsipipe.preprocess.tissue_detection.filters.NullBlur object>, morph_transform=<wsipipe.preprocess.tissue_detection.morphology_transforms.NullTransform object>)[source]

Bases: TissueDetector

Parameters:
class TissueDetectorGreyScale(pre_filter=<wsipipe.preprocess.tissue_detection.filters.NullBlur object>, morph_transform=<wsipipe.preprocess.tissue_detection.morphology_transforms.NullTransform object>, grey_level=0.8)[source]

Bases: TissueDetector

Parameters:

grey_level (float) –

class TissueDetectorOTSU(pre_filter=<wsipipe.preprocess.tissue_detection.filters.NullBlur object>, morph_transform=<wsipipe.preprocess.tissue_detection.morphology_transforms.NullTransform object>)[source]

Bases: TissueDetector

Parameters:

filters module

Filters to apply to images as part of tissue detection

class GaussianBlur(sigma)[source]

Bases: PreFilter

Applies a Gaussian filter with sigma value

Parameters:

sigma (int) –

class MedianBlur(filter_size)[source]

Bases: PreFilter

Applies a median filter of size filter_size

Parameters:

filter_size (int) –

class NullBlur[source]

Bases: PreFilter

Null filter does nothing

class PreFilter[source]

Bases: object

Generic class of filter

morphology_transforms module

Transforms can be applied to binary or labelled images, for example to fill holes

class FillHolesTransform(level_in, hole_size_to_fill=250, level_zero_size=0.25)[source]

Bases: MorphologyTransform

Fills holes in an image, using segmentation Segments smaller than hole_size_to_fill in area are filled. Size of a pixel at the image level is 2**level_in * level zero size Hole_size_to_fill (an area) is converted to number of pixels by dividing by the size of rpixel at image level.

Input image is a binary image Image is segmented using scikit image regionprops. If the area of the region is less than the specified hole size and the mean intensity of the region is less than 0.1 (out of 1) then the region is filled by converting to True/1/white

Args: level_in: level of input image hole_size_to_fill: dark areas smaller in size than this will be filled level_zero_size: size of a pixel at level zero

Parameters:
  • level_in (int) –

  • hole_size_to_fill (float) –

  • level_zero_size (float) –

class MaxPoolTransform(level_in, level_out)[source]

Bases: MorphologyTransform

Applies max pool Takes a big input image and returns a smaller output image. Every pixel in the output image represents 2**(level_out - level_in) pixels in input image. The pixel value for the output image is the maximum of the pixels in that region of the input image.

Args: level_in: Initial level of image level_out: Output level of image (must be a smaller image level_out > level_in)

Parameters:
  • level_in (int) –

  • level_out (int) –

class MorphologyTransform[source]

Bases: object

class NullTransform[source]

Bases: MorphologyTransform

class SimpleClosingTransform[source]

Bases: MorphologyTransform

class SimpleOpeningTransform[source]

Bases: MorphologyTransform

class SizedClosingTransform(level_in, expand_size=50, level_zero_size=0.25)[source]

Bases: MorphologyTransform

Parameters:
  • level_in (int) –

  • expand_size (float) –

  • level_zero_size (float) –

visualise module