This blog entry is incomplete. Equations to get XYZ is wrong.

The other day I was asked how we could get the "difference" of two colors.

RGB value in a CG software is not proportional to what the monitor outputs due to gamma. So we will first correct it. We assume the monitor setting is sRGB. According to sRGB official document (IEC 61966-2-1) we will convert sRGB to XYZ,

We can convert an sRGB value to a linear-RGB value by

Wrong. Should use sRGB->linear-RGB equation.

Then convert it to XYZ.

Wrong. Should use linearRGB->XYZ equation.

if one ore more of R_liner, G_liner, B_linear value is less than 0.0031308, use

Wrong. Should use linearRGB->XYZ equation when linear value is small.instead only for that color(s).

To take color adaptation into account, L*a*b* requires "white point", i.e. ambient light color = your light on the ceiling. To adjust the XYZ colorwhere

- A: (Xn, Yn, Zn) = (109.851, 100, 35.582)
- B : (Xn, Yn, Zn) = (99.095, 100, 98.072)
- C : (Xn, Yn, Zn) = (98.072, 100, 118.225)
- D65: (Xn, Yn, Zn) = (98.072, 100, 108.892)

These are values I found on the net. I still cannot find the accurate way to calculate the value.

Then depending on the value of X', Y', or Z', again if one of more value of them is larger than 0.008856, useor if it is smaller, usefinally,Now you can use above (color diff) equation to get the difference of color.

Basically it is the same as what is written in Wikipedia (at least this moment), except that the Matrix in sRGB->XYZ calculation is a little bit different.

References:

http://www11.tok2.com/home/yoshih/color_index.html (japanese)

http://www005.upp.so-net.ne.jp/fumoto/linkp25.htm(japanese)

http://www.jsa.or.jp/stdz/edu/pdf/b4/4_02.pdf(japanese)

http://idlab.inha.ac.kr/lecture/lecture.pdf(korean)

## No comments:

Post a Comment