2013-01-08 141 views
2

有,你給2種顏色的公式,並得到一個similair顏色,比較L * A * B *顏色

我想知道最近如何做到這一點,它一直在我的腦海捻轉,我有這個公式atm。但是這個不起作用,因爲我沒有得到正確的答案。

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

我有以下的L * a * b *值

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

的答案應該是:

∆E 3,99 

有誰知道至極計算來得到正確的答案?

+0

退房[布魯斯Lindbloom的頁面(http://www.brucelindbloom.com/index.html?Math.html)上顏色方程。特別是,「顏色差異」標題鏈接到幾個Delta E方程。 – Kevin

+0

我現在正在看它,看起來很翔實,但重點是我想比較2 L * a * b顏色並得到答案等於ΔE3,99。我只是不知道如何,我知道這是可能的 –

回答

4

根據Bruce Lindbloom's Color Calculator,使用您擁有的顏色值,如果要獲得3.99的增量E,則應在「紡織品」設置中使用CIE 1994 equation

免費Python實現:

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) 

結果:

3.99245887057 
+0

謝謝你的時間!你的幫助是真實的!這是非常有用的 –

相關問題