Skip to content

Failure to convert XYZ to RGB and back #48

Open
@RobinBol

Description

@RobinBol

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions