Skip to main content

ColorCorrectionPipeline

A stepwise color correction package for scientific images. Fit flat-field correction (FFC), gamma correction (GC), white balance (WB) and color correction (CC) from a chart photograph, then apply the calibration to images captured under the same conditions.

The package builds on ML_ColorCorrection_tool. A desktop interface is available in ColorCorrectionPackage_UI.

The opt-in UI-compatible fitting policy adds linear-light CCM, RPCC2/RPCC3, polynomial, PLS and residual NN algorithms while retaining the existing fitting defaults. fitting_policy="ui-native-v1" adds the native byte-image and FFC/GC fusion rules for new uint8 sRGB calibrations. Apply that mode with predict_image or predict_batch; its documented limits include prepared execution. Existing calibrations keep their recorded rules.

Installation

Python 3.8 or later is required. The qualification matrix covers Python 3.8–3.12 on Windows, Linux and macOS; newer interpreters are not in that matrix.

git clone https://github.com/collinswakholi/ColorCorrectionPackage.git
cd ColorCorrectionPackage
python -m pip install -e ".[performance]"

The performance extra enables optional Numba CPU kernels. Install with python -m pip install -e . for the NumPy fallback. Scientific, Torch, plotting and ONNX Runtime dependencies are included. The separately published PyPI package can be installed with python -m pip install ColorCorrectionPipeline; its features depend on the published version.

Chart detection defaults to the bundled Classic24 ONNX model. It prefers a supported GPU provider and falls back to CPU. See GPU configuration for CUDA, DirectML, WebGPU and CoreML setup and execution diagnostics. Chart detection and color-transform acceleration have separate backend policies.

Calibrate and apply

This example uses the bundled sample photographs, explicitly selects their first frame, and fits a linear-light CCM with native uint8 sRGB image semantics. Numerical policies are opt-in; existing callers retain their recorded stage mathematics and return conventions.

from pathlib import Path
from ColorCorrectionPipeline import ColorCorrection, Config
from ColorCorrectionPipeline.io import write_image_data

output = Path("results")
output.mkdir(exist_ok=True)
pipeline = ColorCorrection()
config = Config(
    do_ffc=True, do_gc=True, do_wb=True, do_cc=True,
    check_saturation=False,
    fitting_policy="ui-native-v1",
    image_options={"frame_index": 0},
    FFC_kwargs={"fit_method": "linear", "bins": 30, "smooth_window": 7},
    CC_kwargs={"model": "ccm"},
    save=True, save_path=str(output), model_format="bundle",
)
metrics, images, failed = pipeline.run(
    "Images/Image_1.JPG", "Images/white.JPG", name_="sample", config=config
)
if failed:
    raise RuntimeError(pipeline.last_run)

# Loading a safe bundle restores the numerical policies and reference context.
restored = ColorCorrection().load_bundle(output / "sample_models.ccpb")
result = restored.predict_image("Images/Sample_1.JPG", stages="final")
record = write_image_data(
    output / "corrected.png", result["CC"],
    dtype="uint8", allow_precision_loss=True,
)

Set do_ffc=False and omit the white image when no matching white-field photograph is available. Enabled stages are required: last_run records stage outcomes, errors, detector execution and persistence diagnostics. A failed fit or save preserves the previous successful calibration.

The existing reproducible-v1 encoded-sRGB fits remain available. Their linear solver minimizes RGB squared error against unclipped reference targets; lower RGB error can increase CIEDE2000, particularly for out-of-gamut references. The fit report records this objective and affected target cells. See fit objectives and perceptual evaluation. Linear-light CCM also optimizes RGB error; evaluate its measured results rather than assuming every correction reduces perceptual error.

Working with the package

Legacy run, predict_image, predict_images, array/image helpers, saved-model formats and import entry points remain available. New contracts and policies do not reinterpret older calibrations. Chart model geometry differs from MCC, so fitting a new calibration can produce different measurements.

The runtime is organized around pipeline.py and config.py; contracts.py, colorimetry.py and observations.py define the interpretation boundaries. detection/ supplies model geometry and provider policy. core/, modern.py, stage_policies.py and fitting.py implement stage execution and fitting. ui_fitting.py and ui_nn.py contain UI numerical fits; ui_native.py records native image semantics and ui_execution.py supplies optional CPU execution. bundle.py handles safe inference artifacts; acceleration.py prepares execution; batch.py, prediction.py, reporting.py and io/ handle application and output. key_functions.py retains historical utility imports for compatibility.

Example output

The illustrations show an example workflow. Chart residuals and appearance do not establish physical color accuracy on independent photographs; results depend on the reference, capture conditions, fit and validation protocol.

Before After
Before correction After correction

Development and qualification

Install developer tools with python -m pip install -e ".[dev,performance]". Build and inspect distributions with:

python -m pip install build twine
python -m build
python -m twine check --strict dist/*
python scripts/verify_distribution.py --output evidence/artifacts.json

The release workflow installs the built wheel into isolated base and performance environments and runs scripts/verify_installed.py, including a real-photo fit, safe-bundle reload, precision I/O and bounded batch processing. See the qualification guide for neutral-directory commands. Generated evidence belongs outside the source tree. Submit changes through a pull request with the relevant numerical and compatibility evidence.

License

Python source is MIT licensed; see LICENSE. Bundled detector models declare AGPL-3.0. Their original license, notices and provenance are retained beside the chart model. Source licensing does not replace the model terms; the provenance record also states the unresolved model ancestry and training-data rights information.

Citation

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.

@software{colorcorrectionpipeline,
  author = {Wakholi, Collins and Rippner, Devin A.},
  title = {ColorCorrectionPipeline: A stepwise color correction pipeline},
  url = {https://github.com/collinswakholi/ColorCorrectionPackage},
  version = {1.5.0},
  year = {2026}
}

Thanks to Devin A. Rippner for technical guidance, ORISE for fellowship support, and USDA-ARS for research support. Report issues and feature requests on GitHub.

Metadata

Release files for ColorCorrectionPipeline 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ColorCorrectionPipeline 1.5.0
File Size Uploaded Provenance Actions
colorcorrectionpipeline-1.5.0.tar.gz 75.0 MB With provenance Details for colorcorrectionpipeline-1.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ColorCorrectionPipeline 1.5.0
File Interpreter ABI Platform Actions
colorcorrectionpipeline-1.5.0-py3-none-any.whl Python 3 none any Details for colorcorrectionpipeline-1.5.0-py3-none-any.whl

Total release size: 146.5 MB

Release files / colorcorrectionpipeline-1.5.0.tar.gz

Download URL colorcorrectionpipeline-1.5.0.tar.gz
Size 75.0 MB
Tags Source
SHA-256 checksum
How to use checksums
ea4c3a8da85721b6fdf1059d701d060bea8b1622f74d8915cbffcaeaf3369498
BLAKE2b-256 checksum
How to use checksums
253ef15b6879d823ccbf0a537227d8b03c850445582a988044a63ac9ac97e18b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / colorcorrectionpipeline-1.5.0-py3-none-any.whl

Download URL colorcorrectionpipeline-1.5.0-py3-none-any.whl
Size 71.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
226da67c25e9c743ecefbcd722539dca60e5a75672db2439f38f9a83f17e35a0
BLAKE2b-256 checksum
How to use checksums
2dab6d1eb412fb13c7b89461067128cd5f88ffb43e87899349f256a7962fc70c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for ColorCorrectionPipeline 1.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for colorcorrectionpipeline-1.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page