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

Failure to convert XYZ to RGB and back #48

Open
RobinBol opened this issue Mar 27, 2020 · 0 comments
Open

Failure to convert XYZ to RGB and back #48

RobinBol opened this issue Mar 27, 2020 · 0 comments

Comments

@RobinBol
Copy link

I have an issue converting an XYZ value to RGB and back, it seems that for some values this works, but for others not. I checked the xyz.max value and all my X/Y/Z values are within range, so that should not be the issue.

This conversion matches (after rounding):

const startXYZ = [47.854955042890886, 29.320696241557958, 21.87902240817543]
const _rgb = colorSpace.xyz.rgb(startXYZ);
const endXYZ = colorSpace.rgb.xyz(_rgb) // => [ 47.854955042890005, 29.320696241558192, 21.879022408175473 ]

However, the following conversion is a mismatch (and quite some other value):

const startXYZ = [ 20, 87, 79 ]
const _rgb = colorSpace.xyz.rgb(startXYZ);
const endXYZ = colorSpace.rgb.xyz(_rgb) // => [ 47.82670703075629, 76.3441771137228, 75.47904959927504 ]

I have been fiddling with the color-convert library as well, but that seems to have the same result (https://github.com/Qix-/color-convert/issues/81). Is this a bug in the conversion algorithm?

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

1 participant