Calibrate a camera setup from one photo of a color chart (a ColorChecker Classic 24, SpyderCHECKR 24 or ColorChecker Digital SG), then apply that calibration to every image taken under the same conditions.
The pipeline corrects, in order: uneven lighting (flat-field correction, from an optional photo of a white target), tone (gamma), color cast (white balance), and remaining color error (color correction).
pip install ColorCorrectionPipelinePython 3.8–3.14 on Windows, Linux and macOS. On Python 3.10+ for Windows, Linux
and Apple-silicon Macs this also installs Numba, which makes fitting and
correcting 10–20× faster with identical results. On Python 3.8/3.9 or an
Intel Mac, add it with pip install "ColorCorrectionPipeline[performance]".
To read compressed 16-bit TIFFs, add [tiff]. Chart detection uses a GPU when
one is available and falls back to the CPU on its own.
You need a photo of the chart and, optionally, a photo of a plain white target taken with the same lighting and camera position.
from ColorCorrectionPipeline import calibrate, correct
cal = calibrate("chart.jpg", white="white.jpg", save_to="calibration.ccpb")
print("Chart error after correction (mean Delta E00):", cal.delta_e)
image = correct("scene.jpg", cal) # RGB float array, values 0–1
image = correct("scene.jpg", "calibration.ccpb") # later, from the saved file- Leave out
white=if you have no white photo; flat-field correction is then skipped. calibrateraisesCalibrationErrorif a stage fails, for example when no chart is found.- The
.ccpbfile is a portable calibration you can share and reload safely.
To save the result as an image file:
from ColorCorrectionPipeline.io import write_image_data
write_image_data("scene_corrected.png", image, dtype="uint8", allow_precision_loss=True)The detector recognises three charts and picks the matching reference values for you:
| Chart | Patches | Status |
|---|---|---|
| ColorChecker Classic 24 (and the Passport's Classic face) | 24 | Fully supported |
| SpyderCHECKR 24 | 24 | New: verified on synthetic charts, not yet on real photos |
| ColorChecker Digital SG | 140 | New: verified on synthetic charts, not yet on real photos |
calibrate() uses whichever chart is in the photo (a Classic wins if there are
several). To choose one, pass chart_type="spyder" or "digital-sg".
If you measured your own chart, use its values instead of the built-in ones:
from ColorCorrectionPipeline import Config, ReferenceProfile, calibrate
reference = ReferenceProfile.from_csv("my_chart.csv", chart="classic") # Lab D50 by default
cal = calibrate("chart.jpg", white="white.jpg", config=Config(reference=reference))Values can be Lab, XYZ or sRGB, under any standard white, in row- or column-major order or labelled by cell. See chart reference values.
from ColorCorrectionPipeline import ColorCorrection
pipeline = ColorCorrection().load_bundle("calibration.ccpb")
results = pipeline.predict_images(["a.jpg", "b.jpg", "c.jpg"], stages="final")
corrected = [r["CC"] for r in results] # same order as the inputstages="final" returns only the finished image, which is faster than keeping
every intermediate stage. See batch processing
for progress callbacks, worker counts and writing results to disk.
The defaults suit most photographs. To change the color model, pass a preset name:
cal = calibrate("chart.jpg", white="white.jpg", model="rpcc3")| Preset | Use when |
|---|---|
rpcc2 (default) |
General use. Robust to exposure changes. |
rpcc3 |
A well-exposed chart and you want a closer fit. |
ccm (or 3x3) |
You want a simple 3×3 matrix. |
pls |
Many correlated features. |
high-precision |
Your scenes are 16-bit or float. |
For anything else, such as turning stages off, flat-field options, neural-network
or PLS models, CPU-only detection, build a
Config:
from ColorCorrectionPipeline import Config, calibrate
config = Config.from_preset("rpcc2", steps={"ffc": {"apply": {"domain": "linear"}}})
cal = calibrate("chart.jpg", white="white.jpg", config=config)The configuration guide has a recipe for each common task and a table of every setting with its default.
The package ships a sample chart, white target and scene:
python -m ColorCorrectionPipeline.examples.quickstart --output demo
python -m ColorCorrectionPipeline.examples.apply_bundle --bundle demo/calibration.ccpb --image my_photo.jpg --output replayThe first command calibrates and writes demo/calibration.ccpb, a corrected
image and the metrics. The second applies that calibration to your own photo.
3.0 removed the old fitting recipes (legacy-v1, reproducible-v1, API-1
configuration dictionaries, MCC detection and key_functions). Requesting one
raises an error that names its replacement. Calibrations saved by 2.x still load
and give the same output. See migrating to 3.0,
or pin ColorCorrectionPipeline==2.3.0 to keep the old recipes.
- Configuration guide: recipes and every setting.
- Batch processing: many images, progress, reports.
- Calibration bundles: the
.ccpbformat. - Reading and saving images: bit depth, color profiles, TIFF and PNG export.
- Chart detection and GPU selection.
- Logging: enable progress messages with
logging.basicConfig(level=logging.INFO). - Fully customizable example: settings in a JSON file, several scenes, TIFF export.
A desktop app with the same workflow is available as ColorCorrect Studio.
pip install -e ".[dev,performance]"
pytest tests
black --check ColorCorrectionPipeline tests scripts
ruff check ColorCorrectionPipeline tests scripts
mypy ColorCorrectionPipelineSee architecture for how the code is organized.
The Python code is MIT licensed. The bundled chart-detection models are AGPL-3.0; see their notices.
If you use this package in research, please cite:
Wakholi, C., Hardigan, M. A., Lee, J., Lukas, S. B., Feldman, M. J., Altendorf, K. R., Neyhart, J. L., & Rippner, D. A. (2026). A systematic color correction pipeline for controlled-environment imaging. The Plant Phenome Journal, 9(1), e70067. doi:10.1002/ppj2.70067
Thanks to Devin A. Rippner for technical guidance, ORISE for fellowship support, and USDA-ARS for research support. Report an issue.