Skip to main content

Estimate a 3D LUT from before/after image pairs and apply it to target images.

Project description

LUT Estimator

License Python

Estimate a 3D LUT from a pair of images and apply that look to another image. The project is packaged as a small Python library with a CLI, so it is easier to reuse in scripts, experiments, and OSS workflows.

Japanese documentation is available in README.ja.md.

Example images are included in the repository under img/ and in the generated sample output files.

Features

  • Estimates a 3D LUT from before/after image pairs using a two-stage interpolation strategy.
  • Applies LUTs with trilinear interpolation to reduce banding artifacts.
  • Supports optional Gaussian blur before estimation to stabilize noisy inputs.
  • Exports the estimated LUT as a standard .cube file.
  • Provides both a Python API and a command-line interface.

Installation

Clone the repository and install it in editable mode:

python -m pip install -e .[dev]

If you only need runtime dependencies:

python -m pip install -e .

Quick Start

Run the CLI with a before/after pair and a target image:

lut-estimator \
  --before img/base.JPG \
  --after img/apply_lut.JPG \
  --target img/base.JPG \
  --output estimated_result.jpg \
  --lut-size 33 \
  --sample-rate 0.02 \
  --blur-ksize 0

This writes:

  • The transformed image to estimated_result.jpg
  • A companion LUT file to estimated_result.cube unless --no-cube is passed

You can also keep using the legacy script entrypoint:

python lut_tool.py --before img/base.JPG --after img/apply_lut.JPG --target img/base.JPG

Python API

from lut_estimator import estimate_and_apply_lut

estimate_and_apply_lut(
    before_image_path="img/base.JPG",
    after_image_path="img/apply_lut.JPG",
    target_image_path="img/base.JPG",
    output_image_path="estimated_result.jpg",
    lut_size=33,
    sample_rate=0.02,
    blur_ksize=0,
    save_cube=True,
    seed=42,
)

Parameters

  • lut_size: LUT grid resolution. Larger values are more accurate but slower.
  • sample_rate: Fraction of pixels used for LUT estimation.
  • blur_ksize: Odd Gaussian kernel size used before estimation. Set 0 to disable blur.
  • seed: Optional random seed for reproducible sampling.

Development

Run tests with:

pytest

Install hooks for local formatting and basic checks:

pre-commit install

Project Structure

src/lut_estimator/
  core.py      Core LUT estimation and application logic
  cli.py       Command-line interface
tests/
  test_core.py Minimal regression tests
lut_tool.py    Backward-compatible entrypoint

Notes

  • Input images are expected to be aligned before/after pairs.
  • If the before/after images have different sizes, both are resized to the smaller common resolution for estimation.
  • The current estimator assumes an RGB-to-RGB global color transform rather than localized edits.

License

Released under the MIT License.

Community

Publishing

Build distributions:

python -m build

Validate package metadata:

python -m twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lut_estimator-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file lut_estimator-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lut_estimator-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for lut_estimator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7aaccbbf53fdd99e78c46dc28b7d4f5bef97bdcf74a46590edadee0ede15c14c
MD5 edd34e4943d27f6c6326538313302228
BLAKE2b-256 7ea46af32896b8a4948e3994e79f210a2a938239b746d8c709eeea37e4293d7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page