normalize-histopathology
Purpose: This package is built to correct faded, discolored Hematoxylin and Eosin (H&E) histopathology scans so archieved slides can be re-analyzed without the need to restain and rescan. The input for this package is a 3-channel (RGB) H&E scan in TIFF format. The core algorithm is Reinhard color transfer with a balanced channel-based correction to avoid artifacts. The output is a 3-channel (RGB) color- and contrast-corrected TIFF, saved as the original filename in the output directory.
Left: original scan. Right: scan corrected by normalize-histopathology.
Installation
pip install normalize-histopathology
# or
uv pip install normalize-histopathology
Usage
1. Install normalize-histopathology into an activated virtual environment
uv venv .venv
source .venv/bin/activate
uv pip install normalize-histopathology
2. Run H&E normalization
normalize-histopathology --input-dir /path/to/original_scans --output-dir /path/to/corrected_scans
Each scan is color-normalized against the default reference slide's
precomputed statistics — no reference image needs to be supplied. You can check the default reference (HE_ref.tif). To
normalize against your own reference slide, provide --ref-path as below:
normalize-histopathology --input-dir /path/to/original_scans --output-dir /path/to/corrected_scans \
--ref-path /path/to/your_reference.tif
CLI arguments:
--ref-pathto normalize against your own reference TIFF instead of the default--patternto change which filenames are matched (repeatable; default:*.tif,*.tiff,*.TIF,*.TIFF)--hmin-scale R G Bto override the per-channel auto-contrast lower-bound scale (default:0.75 0.5 0.333)--debugto print per-image shape/range diagnostics
Troubleshooting tips:
- Input scans should be 3-channel RGB TIFFs; channel-first (
3, H, W) TIFFs are handled automatically. - Very washed-out scans with little tissue contrast left to recover may need a customized
--ref-pathmatched more closely to your stain batch or a caustomized hmin scale. - Make sure you visually check a few corrected outputs before batch-processing an entire cohort.
Additional details on the method
Correction runs in two steps:
| Step | What it does |
|---|---|
| 1. Reinhard LAB normalization | Matches the scan's LAB-space color mean/std to a reference slide, correcting for stain fading and batch-to-batch color drift. |
| 2. Per-channel auto-contrast | Independently rescales each R, G, B channel's histogram, ignoring white background peaks (e.g. slide background). |
Acknowledgement
This tool builds on the Reinhard et al. color transfer method ("Color Transfer between Images", IEEE CG&A, 2001). Many thanks to the scientists and engineers behind that foundational work.
Cite normalize-histopathology
If normalize-histopathology has been useful to your research, please cite our package:
Cao, T. (2026). normalize-histopathology (Version 0.1.0) [Computer software]. Python Package Index. https://pypi.org/project/normalize-histopathology/
Feedback and Questions
We acknowledge that there is no perfect model, but there are some useful ones. We hope to keep improving our tool and support other scientists in their imaging analysis. If you have any feedback, questions, and comments, please send me an email.
License
MIT License
Copyright (c) 2026 Thao Cao
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file normalize_histopathology-0.1.0.tar.gz.
File metadata
- Download URL: normalize_histopathology-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"SLES","version":"15.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd74bb0f1a9c77d0901482f8cb04f6f93447183cf1903379a467cbe9b66ead12
|
|
| MD5 |
fffea04569d274fc671a8f8489271a4e
|
|
| BLAKE2b-256 |
c8aa842ed14ed2c6c4493b20ad24736776e84b80a14a5a35070f3eb3369d41d7
|
File details
Details for the file normalize_histopathology-0.1.0-py3-none-any.whl.
File metadata
- Download URL: normalize_histopathology-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"SLES","version":"15.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d741f1c7cadce869504f202286ccb210c1e86d0c66735703cce27363d076527
|
|
| MD5 |
31de385a6f06bae3e6950fdbdc54970e
|
|
| BLAKE2b-256 |
76a87c09ed824fcad4d2e53836d909f21f49786ae62133947af6580a056decbb
|