Skip to main content

Do color correction of images using machine learning.

Project description

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, CIELuv, CIELCH, CIELCHuv, CIECAM02, etc.)
  4. Add other regression methods (Ridge, Lasso, ElasticNet, etc.)
  5. Refine the white balance methods

Project details


Download files

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

Source Distribution

colorcorrectionML-0.0.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

colorcorrectionML-0.0.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file colorcorrectionML-0.0.2.tar.gz.

File metadata

  • Download URL: colorcorrectionML-0.0.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for colorcorrectionML-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a7fab5cdbee5c19832e52b235e4900c35f6f086cf358743b494f3c30d08affa6
MD5 b90bbe45cf60e5af3968a9165567bfb1
BLAKE2b-256 8c772199ade92f04ba16c235a4afc8e481593ee345270687294595d4123c66c0

See more details on using hashes here.

File details

Details for the file colorcorrectionML-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for colorcorrectionML-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fe7312e20d346bd3afda703299c968ed4c08c36ee9e5cc8888bdc6eae6e04da9
MD5 71bc22c5a275424ca9b2104e79b777cf
BLAKE2b-256 61bf06489c7b70907010d92f0f20d1e8488f750d75c036227f75dc33099193ed

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