[R] grDevices::convertColor XYZ space is it really xyY?

Ken Knoblauch ken.knoblauch at inserm.fr
Wed Jun 12 22:36:46 CEST 2013


You seem to treating the input values as xyY when they should be XYZ
(case matters).
So, I would do something like this

D65 <- c(0.3127, 0.329, 0.3583)

X <- 100 * D65[1]
Y <- 100 * D65[2]
Z <- 100 * D65[3]
XYZ <- data.frame(X = X, Y = Y, Z = Z)

convertColor(XYZ, from = "XYZ", to = "sRGB")
      [,1] [,2] [,3]
[1,]    1    1    1


Quoting Bryan Hanson <hanson at depauw.edu>:

> Ken, I followed your suggestion and perhaps I don't understand what   
> to expect from convertColor or maybe I'm not using it correctly.    
> Consider the following tests:
>
> D65 <- c(0.3127, 0.329, 0.3583) # D65 chromaticity coordinates
> X <- D65[1]*D65[3]/D65[2] # conversion per brucelindbloom.com
> Y <- D65[3]
> Z <- D65[3]*D65[3]/D65[2]
> XYZ <- data.frame(X = X, Y = Y, Z = Z) # D65 in tristimulus values (?)
> colnames(XYZ) <- c("X", "Y", "Z")
>
> tst1 <- convertColor(XYZ, from = "XYZ", to = "sRGB")
> tst2 <- convertColor(D65, from = "XYZ", to = "sRGB")
> # none of these are 1,1,1, namely white (they are ~ 0.6, 0.6, 0.6)
>
> So it looks like D65, a white standard, does not come back to   
> something near white in the sRGB space.  What am I doing wrong here,  
>  or what do I misunderstand?  Please don't say everything!
>
> Thanks, Bryan
>
> On Jun 12, 2013, at 2:57 PM, Ken Knonlauch <ken.knoblauch at inserm.fr> wrote:
>
>> Bryan Hanson <hanson <at> depauw.edu> writes:
>>
>>>
>>> grDevices::convertColor has arguments 'from' and 'to' which can
>> take on value 'XYZ'.  Can
>> someone confirm
>>> that 'XYZ' is the same as the CIE chromaticity coordinates
>> are also sometimes refered to
>> as 'xyY' in
>>> the literature?  Or are these the CIE tristimulus values?
>> It looks to me like the first case is
>> true, but I
>>> would appreciate hearing from one of the people in
>> know.  Thanks, Bryan
>>>
>>>
>>
>> I.'d look at the code or put in some known data to test it,
>> but XYZ are tristimulus values and xyY are chromaticity
>> coordinated and the luminance which is the Y tristimulus
>> value for the CIE 1931 standard observer.
>>
>> Ken
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>



-- 
Kenneth Knoblauch
Inserm U846
Stem-cell and Brain Research Institute
Department of Integrative Neurosciences
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html



More information about the R-help mailing list