histocartography.preprocessing.superpixel module

This module handles everything related to superpixels

Summary

Classes:

ColorMergedSuperpixelExtractor

MergedSuperpixelExtractor

SLICSuperpixelExtractor

Use the SLIC algorithm to extract superpixels.

SuperpixelExtractor

Helper class to extract superpixels from images

class SuperpixelExtractor(nr_superpixels: Optional[int] = None, superpixel_size: Optional[int] = None, max_nr_superpixels: Optional[int] = None, blur_kernel_size: Optional[float] = 1, compactness: Optional[int] = 20, max_iterations: Optional[int] = 10, threshold: Optional[float] = 0.03, connectivity: Optional[int] = 2, color_space: Optional[str] = 'rgb', downsampling_factor: Optional[int] = 1, **kwargs)[source]

Bases: histocartography.pipeline.PipelineStep

Helper class to extract superpixels from images

__init__(nr_superpixels: Optional[int] = None, superpixel_size: Optional[int] = None, max_nr_superpixels: Optional[int] = None, blur_kernel_size: Optional[float] = 1, compactness: Optional[int] = 20, max_iterations: Optional[int] = 10, threshold: Optional[float] = 0.03, connectivity: Optional[int] = 2, color_space: Optional[str] = 'rgb', downsampling_factor: Optional[int] = 1, **kwargs)None[source]

Abstract class that extracts superpixels from RGB Images :param nr_superpixels: The number of super pixels before any merging. :type nr_superpixels: None, int :param superpixel_size: The size of super pixels before any merging. :type superpixel_size: None, int :param max_nr_superpixels: Upper bound for the number of super pixels.

Useful when providing a superpixel size.

Parameters
  • blur_kernel_size (float, optional) – Size of the blur kernel. Defaults to 0.

  • compactness (int, optional) – Compactness of the superpixels. Defaults to 30.

  • max_iterations (int, optional) – Number of iterations of the slic algorithm. Defaults to 10.

  • threshold (float, optional) – Connectivity threshold. Defaults to 0.03.

  • connectivity (int, optional) – Connectivity for merging graph. Defaults to 2.

  • downsampling_factor (int, optional) – Downsampling factor from the input image resolution. Defaults to 1.

precompute(link_path: Union[None, str, pathlib.Path] = None, precompute_path: Union[None, str, pathlib.Path] = None)None[source]

Precompute all necessary information

Parameters
  • link_path (Union[None, str, Path], optional) – Path to link to. Defaults to None.

  • precompute_path (Union[None, str, Path], optional) – Path to save precomputation outputs. Defaults to None.

class SLICSuperpixelExtractor(**kwargs)[source]

Bases: histocartography.preprocessing.superpixel.SuperpixelExtractor

Use the SLIC algorithm to extract superpixels.

__init__(**kwargs)None[source]

Extract superpixels with the SLIC algorithm

class MergedSuperpixelExtractor(**kwargs)[source]

Bases: histocartography.preprocessing.superpixel.SuperpixelExtractor

__init__(**kwargs)None[source]

Extract superpixels with the SLIC algorithm

class ColorMergedSuperpixelExtractor(w_hist: float = 0.5, w_mean: float = 0.5, **kwargs)[source]

Bases: histocartography.preprocessing.superpixel.MergedSuperpixelExtractor

__init__(w_hist: float = 0.5, w_mean: float = 0.5, **kwargs)None[source]

Superpixel merger based on color attibutes taken from the HACT-Net Implementation :param w_hist: Weight of the histogram features for merging. Defaults to 0.5. :type w_hist: float, optional :param w_mean: Weight of the mean features for merging. Defaults to 0.5. :type w_mean: float, optional

Reference

If you use histocartography in your projects, please cite the following:

@inproceedings{pati2021,
    title = {Hierarchical Graph Representations for Digital Pathology},
    author = {Pushpak Pati, Guillaume Jaume, Antonio Foncubierta, Florinda Feroce, Anna Maria Anniciello, Giosuè Scognamiglio, Nadia Brancati, Maryse Fiche, Estelle Dubruc, Daniel Riccio, Maurizio Di Bonito, Giuseppe De Pietro, Gerardo Botti, Jean-Philippe Thiran, Maria Frucci, Orcun Goksel, Maria Gabrani},
    booktitle = {https://arxiv.org/pdf/2102.11057},
    year = {2021}
}