thomasp85 / farver

High Performance Colourspace Manipulation in R
https://farver.data-imaginist.com
Other
125 stars 14 forks source link

conversion from 'xyz' (perceptual) to 'rgb' (sRGB) doesn't seem to work #26

Closed dylanbeaudette closed 3 years ago

dylanbeaudette commented 3 years ago

Any ideas?

# this is the expected output: 0.66387 0.50352 0.38253
convertColor(rbind(c(0.1828, 0.1844, 0.3806)), from = 'XYZ', to = 'sRGB', from.ref.white = 'D65', to.ref.white = 'D65')

# this is not
convert_colour(rbind(c(0.1828, 0.1844, 0.3806)), from = 'xyz', to = 'rgb', white_from = 'D65', white_to = 'D65')
thomasp85 commented 3 years ago

farver is using the native domain of the different colourspaces whereas convertColor normalises it between 0 and 1

convert_colour(rbind(c(0.1828, 0.1844, 0.3806)) * 100, from = 'xyz', to = 'rgb', white_from = 'D65', white_to = 'D65') / 255

will give the same result

It is not all colourspaces that have any defined bounds, so it is not possible to rescale them between 0 and 1. This is why farver leaves the colours alone

dylanbeaudette commented 3 years ago

Thanks. Worth a mention in the manual page? I don't see any such documentation for grDevices::convertColor.