Welcome

Guest

Log out

Subscription valid until 2014-04-18



















 

Color delta/comparison math

These are the formulas to calculate color differences. All of them refers to the CIE-L*ab color space.
Each formula is written as a "neutral programming function", easy to be translate in any specific computer language.
We did not post obvious deltas which involve a simple subtraction of two values.

Please keep in mind that implementing complex delta calculation (CMC, 1994, 2000) in your code may involve a lot of attention about the math itself and also the coding syntax.

Delta C*

Delta H*

Delta E*

Delta E 1994

Delta E 2000

Delta CMC

CIE-L*1, CIE-a*1, CIE-b*1          //Color #1 CIE-L*ab values
CIE-L*2, CIE-a*2, CIE-b*2          //Color #2 CIE-L*ab values

WHT-L, WHT-C                       //Wheight factor


xC1 = sqrt( ( CIE-a*1 ^ 2 ) + ( CIE-b*1 ^ 2 ) )
xC2 = sqrt( ( CIE-a*2 ^ 2 ) + ( CIE-b*2 ^ 2 ) )
xff = sqrt( ( xC1 ^ 4 ) / ( ( xC1 ^ 4 ) + 1900 ) )
xH1 = CieLab2Hue( CIE-a*1, CIE-b*1 )
 
if ( xH1 < 164 || xH1 > 345 ) xTT = 0.36 + abs( 0.4 * cos( dtor(  35 + xH1 ) ) )
else                          xTT = 0.56 + abs( 0.2 * cos( dtor( 168 + xH1 ) ) )
 
if ( CIE-L*1 < 16 ) xSL = 0.511
else                xSL = ( 0.040975 * CIE-L*1 ) / ( 1 + ( 0.01765 * CIE-L*1 ) )
 
xSC = ( ( 0.0638 * xC1 ) / ( 1 + ( 0.0131 * xC1 ) ) ) + 0.638
xSH = ( ( xff * xTT ) + 1 - xff ) * xSC
xDH = sqrt( ( CIE-a*2 - CIE-a*1 ) ^ 2 + ( CIE-b*2 - CIE-b*1 ) ^ 2 - ( xC2 - xC1 ) ^ 2 )
xSL = ( CIE-L*2 - CIE-L*1 ) / WHT-L * xSL
xSC = ( xC2 - xC1 ) / WHT-C * xSC
xSH = xDH / xSH
Delta CMC = sqrt( xSL ^ 2 + xSC ^ 2 + xSH ^ 2 )


CieLab2Hue( var_a, var_b )          //Function returns CIE-H value
{
   var_bias = 0
   if ( var_a >= 0 && var_b == 0 ) return 0
   if ( var_a <  0 && var_b == 0 ) return 180
   if ( var_a == 0 && var_b >  0 ) return 90
   if ( var_a == 0 && var_b <  0 ) return 270
   if ( var_a >  0 && var_b >  0 ) var_bias = 0
   if ( var_a <  0               ) var_bias = 180
   if ( var_a >  0 && var_b <  0 ) var_bias = 360
   return ( rad2deg( atan( var_b / var_a ) ) + var_bias )
}

Top