
This is a Python toolkit for working with whole slide images in digital pathology, the kind of gigapixel H&E or IHC stained tissue scans you get from microscopy. It handles the annoying parts: loading various WSI formats (SVS, TIFF, NDPI), automatically detecting tissue regions versus background, and extracting tiles in sensible ways (random sampling, grid coverage, or scored by nuclei density). The tile extraction strategies are well thought out. RandomTiler for quick sampling, GridTiler for full coverage, ScoreTiler when you want the most informative regions based on cellular content. If you're building computational pathology datasets or preprocessing slides for deep learning pipelines, this handles the boilerplate so you can focus on the actual analysis.
$ npx -y skills add davila7/claude-code-templates --skill histolab --agent claude-codeInstalls into .claude/skills of the current project.
Histolab is a Python library for processing whole slide images (WSI) in digital pathology. It automates tissue detection, extracts informative tiles from gigapixel images, and prepares datasets for deep learning pipelines. The library handles multiple WSI formats, implements sophisticated tissue segmentation, and provides flexible tile extraction strategies.
uv pip install histolab
Basic workflow for extracting tiles from a whole slide image:
from histolab.slide import Slide
from histolab.tiler import RandomTiler
# Load slide
slide = Slide("slide.svs", processed_path="output/")
# Configure tiler
tiler = RandomTiler(
tile_size=(512, 512),
n_tiles=100,
level=0,
seed=42
)
# Preview tile locations
tiler.locate_tiles(slide, n_tiles=20)
# Extract tiles
tiler.extract(slide)
Load, inspect, and work with whole slide images in various formats.
Sponsors