# Delta E (CMC)

The color difference method of the Color Measurement Committee (the CMC) is a model using two parameters l and c, typically expressed as CMC(l:c). Commonly used values for acceptability are CMC(2:1) and for perceptibility are CMC(1:1).

The color difference, or $\Delta E$, between a sample color ($L_2$, $a_2$, $b_2$) and a reference color ($L_1$, $a_1$, $b_1$) is:

$$\Delta E = \sqrt{ \left({{\Delta L} \over {l S_L}}\right)^2 + \left({{\Delta C} \over {c S_C}}\right)^2 + \left({{\Delta H} \over {S_H}}\right)^2 }$$

where

$$\Delta C = C_1 - C_2$$ $$C_1 = \sqrt{{a_1}^2 + {b_1}^2}$$ $$C_2 = \sqrt{{a_2}^2 + {b_2}^2}$$ $$\Delta H = \sqrt{{\Delta a}^2 + {\Delta b}^2 - {\Delta C}^2}$$ $$\Delta L = L_1 - L_2$$ $$\Delta a = a_1 - a_2$$ $$\Delta b = b_1 - b_2$$ $$S_L = \cases{ 0.511 & \text{if }L_1 \lt 16 \\ {{0.040975 L_1} \over {1 + 0.01765 L_1}} & \text{if }L_1 \geq 16 }$$ $$S_C = {{0.0638 C_1} \over {1 + 0.0131 C_1}} + 0.638$$ $$S_H = S_C (FT+1-F)$$ $$T = \cases{ 0.56 + |0.2 \cos (H_1 + 168°)| & \text{if }164° \leq H_1 \leq 345° \\ 0.36 + |0.4 \cos (H_1 + 35°)| & \text{otherwise} }$$ $$F = \sqrt{{C_1^4} \over {C_1^4 + 1900}}$$ $$H = \arctan \left({b_1} \over {a_1}\right)$$ $$H_1 = \cases{ H & \text{if }H \geq 0 \\ H + 360° & \text{otherwise} }$$

Implementation Notes:

1. $H_1$ is in degrees, not radians.
2. In computing $H$, be careful with the inverse tangent since $a_1$ could be zero. Instead, use special math functions to do this. In the Standard C library and most other math libraries, this function is called atan2 and is used calling atan2(b, a). In Microsoft Excel, it is called ATAN2 and its use is ATAN2(a, b). Note the argument reversal! These special functions will compute the proper inverse tangents without needing to worry about "divide by zero" conditions. Additionally, atan2 will also handle the quadrants for you.
3. Math libraries generally return inverse tangents in radians, not degrees. In Excel, use the DEGREES function to convert radians to degrees.
4. Math libraries generally require the input to the cosine function to be in radians, not degrees. In Excel, use the RADIANS function to convert degrees to radians.