histolab

Lightweight WSI tile extraction and preprocessing. Use for basic slide processing, tissue detection, tile extraction, and stain normalization for H&E images. Best for simple pipelines, dataset preparation, and quick tile-based analysis. For advanced spatial proteomics, multiplexed imaging, or deep learning pipelines use pathml.

Install

Hot:7

Download and extract to your skills directory

Copy command and send to AI Agent for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-histolab&locale=en&source=copy

Histolab - Lightweight Pathology Image Processing and Tiling Extraction Tool

Skill Overview

Histolab is a Python library designed specifically for digital pathology. It processes whole-slide images (WSI) to enable tissue detection, information tile extraction, and deep learning dataset preparation.

Use Cases

1. Preparing Deep Learning Pathology Image Datasets


Use Histolab to extract large volumes of high-quality image tiles from pathology slides for training deep learning models such as CNNs and Transformers. It supports three extraction strategies: random sampling, grid coverage, and score-driven extraction. Tiles can be selected based on metrics such as tissue density and the number of nuclei to obtain the best tiles.

2. Image Preprocessing and Analysis for Digital Pathology


Automatically identify tissue regions in H&E-stained pathology slides, filter out background, and perform stain normalization to ensure color consistency across multiple slides. Suitable for tasks such as image quality assessment, tissue segmentation, and quantitative analysis in pathology research.

3. Visualization and Quality Assessment of Pathology Slides


Rapidly generate pathology slide thumbnails, visualize tissue masks, and preview tile locations. Supports batch processing of multiple slides and generation of quality reports. Useful for pathologists to quickly browse samples, assess staining quality, and provide preprocessed images for annotation work.

Core Features

1. Intelligent Tissue Detection and Mask Generation


Automatically identify and segment tissue regions in pathology slides, excluding background and traces of manual annotations. Offers three mask strategies: TissueMask (full tissue segmentation), BiggestTissueBoxMask (largest tissue region), and a customizable BinaryMask. Detection sensitivity can be adjusted using morphological filters to accommodate slides with different staining qualities and tissue types.

2. Multi-Strategy Tile Extraction


Provides three tile extraction methods: RandomTiler (random sampling, suitable for dataset construction), GridTiler (grid coverage, suitable for whole-slide analysis), and ScoreTiler (score-driven extraction, prioritizing information-dense regions). Supports extraction across multiple pyramid levels, overlap control, tissue-content filtering, and custom scoring functions (e.g., NucleiScorer for nuclei density scoring).

3. Stain Normalization and Preprocessing


Includes two built-in stain normalization algorithms: Macenko and Reinhard. These eliminate staining differences between different slides and scanners, ensuring consistency in deep learning training data. Provides a rich image-processing filter pipeline—including grayscale conversion, adaptive thresholding, morphological operations, removal of small objects, etc.—to build customized tissue detection and quality control workflows.

Common Questions

What image formats does Histolab support? What are the system requirements?


Histolab supports multiple WSI formats via OpenSlide, including SVS, TIFF, NDPI, SCN, BIF, and others. You need to install the OpenSlide system library first, then install Histolab with uv pip install histolab. Histolab 0.7.0 supports Python 3.8–3.11 and is compatible only with Linux and macOS. Windows users can use WSL or Docker.

How is Histolab different from PathML? How should I choose?


Histolab focuses on a basic pathology image processing pipeline for scenarios such as simple tile extraction, tissue detection, and stain normalization, with concise code and a quick learning curve. PathML targets advanced spatial proteomics, multi-modal imaging, and complex deep learning pipelines, offering richer data types and analysis capabilities. If your needs are basic dataset preparation and fast tile analysis, choose Histolab first. If you need to handle multi-label data or build end-to-end ML pipelines, consider using PathML.

How do I use Histolab to prepare deep learning training data?


A typical workflow: 1) Use the Slide class to load the pathology slide and check the thumbnail to confirm tissue presence; 2) Use locate_mask() to preview the tissue mask and adjust filter parameters if necessary; 3) Select a suitable extractor (e.g., set n_tiles=1000 in RandomTiler) and use locate_tiles() to preview tile locations; 4) Call the extract() method to extract tiles to a specified directory, with an option to generate a CSV report recording tile metadata and scores. The entire process supports logging and batch processing of multiple slides.