This repository focuses on thumbnail-level tissue segmentation on CAMELYON16. The main objective was to design a tissue masking pipeline that is accurate enough to be useful in practice, while still being fast and interpretable. The benchmark and the report were built around that goal: they are there to evaluate the pipeline properly and to show what actually improves it.
The project centers on one hand-designed method and one learned extension. ALBS was built directly out of classical preprocessing techniques, especially background estimation, non-gray filtering, and morphology. The main question behind the work is simple: can a strong classical tissue masker go far enough on its own, and if not, where does a small learned refiner add real value?
- ALBS (Adaptive Lab Background Subtraction): a hand-designed tissue masker created from classical preprocessing techniques such as Lab-space background estimation, non-gray filtering, and morphology.
- ALBSRefiner: a compact neural second stage that takes the ALBS mask as a prior and learns local corrections for harder cases such as fragmented tissue and uncertain boundaries.
The main narrative entry point is notebooks/main_report.ipynb. If you want the script-oriented workflow first, see benchmarks/README.md.
- Problem: separate tissue from background on histopathology thumbnails.
- Main goal: build a tissue-segmentation pipeline that is both accurate and practical to use.
- Core method:
ALBS, a fast and interpretable masker built from classical preprocessing techniques. - Extension:
ALBSRefiner, which keeps ALBS as the starting point and learns local corrections. - How it is validated: a reproducible benchmark and report that measure accuracy, runtime, and failure cases.
- Best place to start: notebooks/main_report.ipynb.
- On the full 395-thumbnail benchmark,
ALBSreaches 0.838 mean Dice, which is the strongest classical result among the baselines included here. - On the locked holdout split (
300train /95test),ALBSRefinerreaches 0.913 Dice and improves overALBS, which reaches 0.844 Dice. - On that same holdout,
ALBSaverages 17.70 ms per thumbnail, whileALBSRefineraverages 56.36 ms.
Sources:
reports/main/tables/method_summary_full395.csvreports/main/tables/method_summary_holdout_test95.csv
CAMELYON16 is a public computational pathology dataset built around whole-slide lymph node images, with tumor and normal cases and annotations that make it useful for downstream cancer-detection research. In this repository, the work is done at thumbnail level, but the dataset still gives the project a real and recognizable pathology setting instead of a private or toy example.
It was chosen because it is widely used, relevant to real digital pathology workflows, and strong enough to make the tissue-segmentation task meaningful. Using CAMELYON16 makes it easier to evaluate whether the proposed masking pipeline is actually useful on realistic data rather than only on hand-picked examples.
This project works on thumbnails rather than full whole-slide resolution on purpose. It keeps iteration manageable, makes side-by-side benchmarking much easier, and isolates the tissue-versus-background problem clearly before moving to heavier tile-level inference. In a real whole-slide pipeline, that still matters, because a thumbnail-level tissue mask is a practical first filter for removing obvious background and focusing later computation.
Whole-slide images are very large, and a lot of that area is often empty background. If a downstream model has to process everything, it wastes time and compute on regions that are not useful.
That is why tissue masking matters here. A good tissue mask acts as a first filter: it removes obvious background, reduces the number of tiles that need to be processed later, and keeps the pipeline focused on the regions that actually contain tissue.
In this project, that is the practical role of ALBS. Even before the learned refiner is introduced, the method is meant to be a fast and interpretable preprocessing step that makes later analysis more efficient.
The report notebook follows a clear progression:
- Dataset inspection and thumbnail-level EDA.
- Design and intuition behind ALBS.
- Full benchmark across the 395-image sample.
- Error analysis to understand where ALBS struggles.
- Motivation for a learned refiner.
- Locked-holdout evaluation of
ALBSRefiner. - Holdout error analysis, grouped gains, and qualitative case studies.
- Final conclusions.
That structure is important for this repo. It is best read as a solution-oriented technical case study: the segmentation pipeline is the main subject, and the benchmark is the evidence used to test and refine it.
Open the main report:
jupyter lab notebooks\main_report.ipynb
If you mainly want to inspect generated outputs first, a good starting set is:
reports/main/figures/full_benchmark_quality_speed.pngreports/main/figures/albs_feature_correlations_full395.pngreports/main/figures/albs_dev_best_worst.pngreports/main/figures/holdout_delta_dice_hist_refiner_vs_albs.pngreports/main/figures/holdout_refiner_delta_breakdown_by_group.png
Create a virtual environment and install the benchmark dependencies:
python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install -r benchmarks\requirements.txt
If you want to train the refiner yourself, also install:
python -m pip install -r benchmarks\requirements_refiner.txt
Quick smoke test:
python -m benchmarks.tissue_benchmark --limit 10 --output-csv .tmp\benchmark_results.csv
Full 395-image benchmark with the main classical baselines:
python -m benchmarks.tissue_benchmark --methods albs,qupath_simple_equivalent,histoqc_equivalent,clam_hsv_otsu,tiatoolbox_otsu,tiatoolbox_morphological,histomicstk,histolab_equivalent --output-csv reports\main\tables\benchmark_results_full395.csv
Locked-holdout comparison between ALBS and ALBSRefiner:
python -m benchmarks.tissue_benchmark --split-json .cache\splits\camelyon16_holdout_seed42.json --subset test --methods albs,albs_refiner --output-csv reports\main\tables\benchmark_results_holdout_test95.csv
If you want to include GrandQC in a run, add grandqc_tissue to --methods and either pass --download-grandqc or provide --grandqc-weights <path>.
notebooks/contains the main report notebook and the supporting refiner notebook.benchmarks/contains the benchmark runner, baseline implementations, split generation, and refiner training code.reports/main/contains the saved figures and tables used by the report.tests/contains the current regression and model checks..cache/stores the holdout split, refiner artifacts, and optional downloaded weights.
The main supported workflow is: run the benchmark code when needed, then read the results through notebooks/main_report.ipynb.
Run the current test suite with:
python -m unittest -v
ALBS and ALBSRefiner are the methods proposed in this repository. The list below covers the external baselines and tools used for comparison.
Some baselines are called through the original Python packages, while others are equivalent-style thumbnail reimplementations collected in benchmarks/baselines.py so everything can be compared in one reproducible workflow.
QuPath Simple Equivalent: based on QuPath's simple tissue detection command. This repo uses a thumbnail-level equivalent implementation rather than QuPath itself. Source: QuPath commands docsHistoQC Equivalent: based on the foreground masking approach used in HistoQC. This repo uses an equivalent-style thumbnail implementation. Source: HistoQC repositoryCLAM HSV Otsu: based on the public CLAM preprocessing / tissue segmentation workflow. This repo uses a lightweight baseline in that style. Source: CLAM repositoryTIAToolbox OtsuandTIAToolbox Morphological: official TIAToolbox tissue maskers used through the Python package. Source: TIAToolbox tissue masking docsHistomicsTK: wrapssaliency.tissue_detection.get_tissue_maskfrom HistomicsTK. Source: HistomicsTK simple tissue detection docsHistolab Equivalent: based on Histolab tissue masks and default filtering steps. This repo uses an equivalent implementation for compatibility and easier benchmarking on Python 3.11. Source: Histolab tissue mask docsGrandQC Tissue: based on the public GrandQC tissue model. Source: GrandQC repository
Additional background references that fit the broader whole-slide preprocessing and tissue-masking context:
Whole-Slide Image Preprocessing in Python: practical walkthrough of whole-slide preprocessing steps in Python. Source: python-wsi-preprocessing documentationA novel method for tissue segmentation in high-resolution H&E-stained histopathological whole-slide images: background paper on tissue segmentation in histopathology WSIs. Source: ScienceDirect article
- The bundled sample data lives under
CAMELYON_16_samples/thumbnails/. - The current report expects the cached split file and refiner artifacts in
.cache/. - The refiner notebook is notebooks/train_eval_albs_refiner.ipynb.