Git Product home page Git Product logo

colorcorrectionmatrix's Introduction

Compute Color Correction Matrix (CCM)

We compute Color Correction Matrix A. In other words, we calculate a 4x3 matrix A which approximate the following equation.

Let P be a reference color checker matrix (24 x 3) and O be a color checker matrix to correct (24 x 3).
P = [O 1] A

reference image to correct

Data

We have to prepare color checker patch data as csv format. There are example data in data directory.

  • data/colorchart_photo_strobo_linear.csv
  • data/colorchart_rendered_strobo_linear.csv

They are 24x3 matrix. The data are made by reading pixel values using Natron2

Dependency

  • Python
    • numpy
    • matplotlib
    • Pillow
    • OpenEXR
  • C++
    • args.hxx(included in this repo)
    • Eigen3

Build c++ version of computeCCM

$ cd cpp
$ mkdir build
$ cmake ../
$ make

Usage

# computeCCM.py [-h] [-g GAMMA] reference_csv source_csv output_csv
$ computeCCM.py data/colorchart_photo_strobo_linear.csv data/colorchart_rendered_strobo_linear.csv ccm.csv

This command generates optimal Color Correction Matrix as csv file (ccm.csv)

Test

We can compare reference data and corrected data using plotChart.py

$ plotChart.py ccm.csv data/colorchart_photo_strobo_linear.csv data/colorchart_rendered_strobo_linear.csv ccm.csv chart

plot chart

Each patch shows reference color and corrected color. Upper one is reference and lower one is corrected color. The numbers mean relative error.

Color Correction

Correct given image using CCM. correctColor.py reads jpg or png images, and correctColorExr.py reads exr images.

Usage

$ correctColor.py ccm.csv reference.png corrected

result
corrected image

Image Diff

Generate diff image between a reference image and a corrected image. We compute a difference between two images and take average of rgb for each pixels.

Usage

$ imageDiff.py photo_reference.png corrected.png

diff

The difference is small as the color approaches blue and the difference is big as the color approaches red.

License

CCM is licensed under MIT license.

Third party licenses

  • args.hxx is licensed under MIT License
  • Eigen is licensed under Mozilla Public License

References

colorcorrectionmatrix's People

Contributors

soma-arc avatar syoyo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.