-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error in Delta E algorithm #85
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this! Could you explain what issue it fixes?
src/deltaE/deltaE2000.js
Outdated
let Δh; | ||
|
||
if (Cdash1 == 0 && Cdash2 == 0) { | ||
if (Cdash1 * Cdash2 == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to use ===
here? (question to both you and @svgeesus )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I didn't use ===
because I write in many languages and accidentally didn't use JS ===
.
I believe I explain it in issue #84. The algorithm isn't correct and will yield different results than intended.
The second case may not be a problem at all. If |
I double checked. Since if (h1 < 0) {
h1 += 2 * π;
}
if (h2 < 0) {
h2 += 2 * π;
} Then I think I reverted those changes but kept the |
I've been able to confirm that changing from So, in general, maybe there is some clever optimization here which is why It is possible that |
I ran a much more extensive test, and still see no difference in the final output. As a matter of fact, I even disabled the condition under the
IMHO, I think being true to the spec, in this case, is less confusing, but I also can't argue that my change actually improves anything except being more true to the spec 🙃. So, feel free to close if you find no value in this. |
Many thanks for testing and yes as @danburzo said
but still, as so many other deltaE2000 implementations are incorrect in small ways for some color combinations, I was going for verifiable correctness. Sadly the Sharma testsuite does not include a test for Eqn(10 being correctly implemented. |
Fixes #84