Skip to main content

ColorCorrectionML

ColorCorrectionML is a Python package for color correction of images using machine learning. It uses ML regression methods (linear, least sqaure, and partial least squares regression) to learn the color correction function from a training image with a color checker. The learned function is then applied to correct the color of a test image.

Installation

pip install colorcorrectionML

Usage

from ColorCorrectionML import ColorCorrectionML
import cv2

img = cv2.imread('Images/img2.png')

cc = ColorCorrectionML(img, chart='Classic', illuminant='D50')

method = 'pls' # 'linear', 'lstsq', 'pls' 
# for linear regression, least square regression, and partial least square regression respectively
show = True

kwargs = {
    'method': method,
    'degree': 3, # degree of polynomial
    'interactions_only': False, # only interactions terms,
    'ncomp': 10, # number of components for PLS only
    'max_iter': 5000, # max iterations for PLS only
    'white_balance_mtd': 0 # 0: no white balance, 1: learningBasedWB, 2: simpleWB, 3: grayWorldWB,
    }

M, patch_size = cc.compute_correction(
    show=show,
    **kwargs
)
    

# resize img by 2
# img = cv2.resize(img, (0,0), fx=0.3, fy=0.3, interpolation=cv2.INTER_AREA)

img_corr = cc.correct_img(img, show=True)
# img_corr = cc.Parallel_correct_img(img, chunks_=50000, show=True)

Example results

Scatter plot of the original image and the corrected image color values scatter plot

Color correction results color correction results

TODO

  1. Add other reference color values (D55, D65, D70, D75)
  2. Add other color charts (ColorChecker24, ColorCheckerSG, ColorCheckerDC)
  3. Add other color spaces (CIELab, XYZ, etc.)
  4. Add other regression methods (Ridge, Lasso, ElasticNet, etc.)
  5. Refine the white balance methods

Metadata

Release files for colorcorrectionML 0.0.2.1

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

Source distribution (sdist)

Source distribution for colorcorrectionML 0.0.2.1
File Size Uploaded
colorcorrectionML-0.0.2.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for colorcorrectionML 0.0.2.1
File Interpreter ABI Platform
colorcorrectionML-0.0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / colorcorrectionML-0.0.2.1.tar.gz

Download URL colorcorrectionML-0.0.2.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
576a91a84e605bc9ed16fef8ab889a7b8ce970dd346db3f263684d67b3316e1b
BLAKE2b-256 checksum
How to use checksums
3c6421b299ab50da533c204f2bb4f8cad181d890cb92f03733907815f896effc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / colorcorrectionML-0.0.2.1-py3-none-any.whl

Download URL colorcorrectionML-0.0.2.1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3ed17dc786c8dc11f66da728063a7d13495ce79d861cd6e792031a0f1e50bcc4
BLAKE2b-256 checksum
How to use checksums
3904048a6d3e3d2cc26df26e5810b5b7f0859b33bfe673da0b508b6188bd9a1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.0.2.1 This release

2 release files

0.0.2

2 release files

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