Skip to content
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

LAB incorrectly converted #43

Open
strarsis opened this issue Sep 21, 2018 · 4 comments
Open

LAB incorrectly converted #43

strarsis opened this issue Sep 21, 2018 · 4 comments

Comments

@strarsis
Copy link

LAB colour: 60, -28, -32
RGB (converted): 0, 160, 200

const one = require('onecolor');
var color = one([ 'LAB', 60, -28, -32 ]);
console.log(color.css());

Output:

rgb(93,93,93)

The calculated RGB value of 93, 93, 93 results in different colour (visually) and
also doesn't match the expected RGB value of 0, 160, 200.

@Munter
Copy link
Collaborator

Munter commented Sep 23, 2018

Lab and xyz color spaces are not well tested, and thus marked as experimental so far.

If you have actually will known conversions that should work and have any reference to the correct color math I would be very happy to take a look at revisiting these.

A PR with failing color conversions would be very helpful as well

@papandreou
Copy link
Collaborator

I don't know anything about the LAB colorspace, but there must be something fishy. Conversions from rgb to lab and back again don't result in the same color, unless you dial up the epsilon way up:

oneColor('rebeccapurple').lab().rgb().equals(oneColor('rebeccapurple'), .2) // false
oneColor('rebeccapurple').lab().rgb().equals(oneColor('rebeccapurple'), .3) // true

@strarsis
Copy link
Author

strarsis commented Sep 23, 2018

@Munter: For the example above I just used some online converters like https://www.nixsensor.com/free-color-converter/.
I noticed this issue with basically all input lab colours, hence I think there is a systematic issue.

@Munter
Copy link
Collaborator

Munter commented Sep 24, 2018

I wouldn't be surprised that it's completely broken. Both XYZ and LAB were me just implementing it from a maths page without having any form of conversion examples I could plug in for testing.

There's also the problem that you have to choose a reference whitepoint (https://github.com/One-com/one-color/blob/master/lib/XYZ.js#L14-L21) and all examples I could find differ greatly. So I simply had no idea how to make a correct implementation and where to find any resource that would be considered correct

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

No branches or pull requests

3 participants