Mr chinpansee
Mr chinpansee

Reputation: 375

comparing l*a*b* colors

There are formulas where you give 2 colors, and getting an similair color,

I'm wondering lately how that is done, its been twirling in my head, I have this formula atm. But this one doesnt work since im not getting the correct answer.

   so you have to look for a different formula then this one.
   ∆E = √{ (L2 - L1)² + (A2 - A1)² + (B2 - B1)²  }

I have the following L*a*b* values

      L1 89,24  |   A1 -0,6     |       B1 = 91,29
      L2 81,61  |   A2 -2,72    |       B2 = 87,59

The answer as should be:

∆E 3,99

Does anyone know wich calculation is used to get the right answer?

Upvotes: 2

Views: 548

Answers (1)

Kevin
Kevin

Reputation: 76234

According to Bruce Lindbloom's Color Calculator, using the color values you have, if you want to get a delta E of 3.99, you should use the CIE 1994 equation, on the "textiles" setting.

Complimentary Python implementation:

import math

class Lab:
    def __init__(self, l, a, b):
        self.l = l
        self.a = a
        self.b = b

def cie1976(a, b):
    dl = a.l - b.l
    da = a.a - b.a
    db = a.b - b.b
    return math.sqrt(dl*dl + da*da + db*db)

def cie1994(x, y, isTextiles=True):
    k2 = 0.014 if isTextiles else 0.015
    k1 = 0.048 if isTextiles else 0.045
    kh = 1
    kc = 1
    kl = 2 if isTextiles else 1

    c1 = math.sqrt(x.a*x.a + x.b*x.b)
    c2 = math.sqrt(y.a*y.a + y.b*y.b)

    sh = 1 + k2*c1
    sc = 1 + k1*c1
    sl = 1

    da = x.a - y.a
    db = x.b - y.b
    dc = c1 - c2

    dl = x.l - y.l
    dh = math.sqrt(da*da + db * db - dc*dc)

    return math.sqrt((dl/(kl*sl))**2 + (dc/(kc*sc))**2 + (dh/(kh*sh))**2)

a = Lab(89.24, -0.6, 91.29)
b = Lab(81.61, -2.72, 87.59)

print cie1994(a,b)

Result:

3.99245887057

Upvotes: 4

Related Questions