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
Metadata
Release files for normalize-histopathology 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| normalize_histopathology-0.1.0.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| normalize_histopathology-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.2 kB
Release files / normalize_histopathology-0.1.0.tar.gz
| Download URL | normalize_histopathology-0.1.0.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd74bb0f1a9c77d0901482f8cb04f6f93447183cf1903379a467cbe9b66ead12
|
|
BLAKE2b-256 checksum How to use checksums |
c8aa842ed14ed2c6c4493b20ad24736776e84b80a14a5a35070f3eb3369d41d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / normalize_histopathology-0.1.0-py3-none-any.whl
| Download URL | normalize_histopathology-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d741f1c7cadce869504f202286ccb210c1e86d0c66735703cce27363d076527
|
|
BLAKE2b-256 checksum How to use checksums |
76a87c09ed824fcad4d2e53836d909f21f49786ae62133947af6580a056decbb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|