Skip to content

Conversation

@matthewbaggett
Copy link

No description provided.

@matthewbaggett
Copy link
Author

Fix issues, add CIE XYBri support, add Initial PHPUnit tests and Travis support.

@DeannaGelbart
Copy link

DeannaGelbart commented Jul 19, 2016

getDistanceLabFrom() is not a Euclidean distance since it uses abs() instead of squaring
https://en.wikipedia.org/wiki/Color_difference#CIE76

Once I make the change the result seems to match http://colormine.org/delta-e-calculator (I only checked one color pair in the calculator so I didn't test exhaustively).

Here is my fixed version

public function getEuclideanDistanceLab(Color $color1, Color $color2)
{
    $lab1 = $color1->toLabCie();
    $lab2 = $color2->toLabCie();

    $lDiff = ($lab2['l'] - $lab1['l'])*($lab2['l'] - $lab1['l']);
    $aDiff = ($lab2['a'] - $lab1['a'])*($lab2['a'] - $lab1['a']);
    $bDiff = ($lab2['b'] - $lab1['b'])*($lab2['b'] - $lab1['b']);

    $delta = sqrt($lDiff + $aDiff + $bDiff);

    return $delta;
}

I can submit a PR but I want to check first that this project is still active?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants