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
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
- Python
- numpy
- matplotlib
- Pillow
- OpenEXR
- C++
- args.hxx(included in this repo)
- Eigen3
$ cd cpp
$ mkdir build
$ cmake ../
$ make
# 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
)
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
Each patch shows reference color and corrected color. Upper one is reference and lower one is corrected color. The numbers mean relative error.
Correct given image using CCM.
correctColor.py
reads jpg or png images, and
correctColorExr.py
reads exr images.
$ correctColor.py ccm.csv reference.png corrected
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.
$ imageDiff.py photo_reference.png corrected.png
The difference is small as the color approaches blue and the difference is big as the color approaches red.
CCM is licensed under MIT license.
- RGB coordinates of the Macbeth ColorChecker, Danny Pascale. June 1st, 2006 version. http://www.babelcolor.com/index_htm_files/RGB%20Coordinates%20of%20the%20Macbeth%20ColorChecker.pdf
- Color Correction Matrix http://www.imatest.com/docs/colormatrix/
- Raw-to-raw: Mapping between image sensor color responses. CVPR 2014. https://www.cv-foundation.org/openaccess/content_cvpr_2014/papers/Nguyen_Raw-to-Raw_Mapping_between_2014_CVPR_paper.pdf