Color Profiling

From apertus wiki
Jump to: navigation, search
cat IT8.raw16 | python CMV12000toDNG.py
  • Rename the file
mv img.dng IT8.dng
  • Convert DNG to linear TIFF
dcraw -r 1 1 1 1 -M -H 0 -o 0 -4 -T IT8.dng
  • Crop image if necessary to only show IT8 chart. Save as .tif or .png
  • Run scanin (from Argyll)
scanin -v IT8_crop.tif it8.cht R100604.txt, Note it8.cht comes with Argyll in a subdirectory. R100604.txt was the measured values supplied with the IT8 chart. The output file will be IT8_crop.ti3
  • Run colprof (from Argyll)
colprof -v -y -A "apertus" -M "Axiom Alpha" -D "CMV12000 2900k" -C "None" -qh -am -nc -U1.15 IT8_crop

Note that you do not need to add the .ti3 extension. Argyll will look and find the file as long as the previous step was successful.

Look for the output XYZ to Device matrix:
Matrix = 0.708155 0.545110 0.291357
         0.370203 1.280726 -0.220406
         0.159994 0.082272 2.033974

Also note the error:

Profile check complete, peak err = 78.849183, avg err = 20.547190

Note in this case the avg error is extremely high.

Colprof should have output IT8_crop.icc. How you apply the profile will depend on what software you are using. For our case we want to embed the matrix in the DNG so the raw processor knows how to map from camera space to XYZ space.

In order to do that, we must invert the matrix. You may use your favorite math package to do that:

In Python with numpy:

from numpy import linalg

import numpy as np

XYZtoCamera = np.array([[0.708155,0.545110,0.291357],[0.370203,1.280726,-0.220406],[0.159994,0.082272,2.033974]])
CameratoXYZ = linalg.inv(XYZtoCamera)
print(CameratoXYZ)
[[ 1.90486644 -0.78774839 -0.35822515]
 [-0.572417    1.01212979  0.19167265]
 [-0.12668466  0.02102538  0.5120737 ]]

or use an example website:

http://ncalculators.com/matrix/inverse-matrix.htm

DNG allows you to specify the matrix as rational numbers with a numerator and denominator. For example, we can multiply the matrix by 10,000, enter the integer values in the numerators in the matrix, and specify 10,000 in the denominators:

10000*CameratoXYZ
array([[ 19048.66437109,  -7877.48389553,  -3582.25150402],
       [ -5724.16995777,  10121.29789429,   1916.72645278],
       [ -1266.8466247 ,    210.25378792,   5120.73695554]])

So in CMV12000toDNG.py we replace with:
# Camera calibration
matrix1Tag = dng.ifd.getTag('ColorMatrix1')
matrix1Tag.value[0].num = 19049
matrix1Tag.value[1].num = -7877
matrix1Tag.value[2].num = -3582
matrix1Tag.value[3].num = -5724
matrix1Tag.value[4].num = 10121
matrix1Tag.value[5].num = 1917
matrix1Tag.value[6].num = -1267
matrix1Tag.value[7].num = 210
matrix1Tag.value[8].num = 5121

matrix1Tag.value[0].denom = 10000
matrix1Tag.value[1].denom = 10000
matrix1Tag.value[2].denom = 10000
matrix1Tag.value[3].denom = 10000
matrix1Tag.value[4].denom = 10000
matrix1Tag.value[5].denom = 10000
matrix1Tag.value[6].denom = 10000
matrix1Tag.value[7].denom = 10000
matrix1Tag.value[8].denom = 10000

Then reprocess the raw16 file with the new matrix to get the new *.dng and open in your raw processor of choice.