Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In Mathematica, producing a color based on its RGB parameters is easy; one can use (for example)

Graphics[{RGBColor[0.8, 0.6, 0.5], Rectangle[]}, ImageSize -> 100]

or

Image[{{{0.8, 0.6, 0.5}}}, Automatic, ColorSpace -> "RGB", ImageSize -> 100]

This produces a square as follows:

RGB Color Sample

The range of values for each of the r, g, b parameters are from 0 to 1, as listed in the documentation. Any value of out of this range will be clipped.

However, if I would like to produce a color based on its CIE XYZ color, I can still do as follows

Image[{{{0.8, 0.6, 0.5}}}, Automatic, ColorSpace -> "XYZ", ImageSize -> 100]

XYZ Color Sample

Note that the color produced will be visually different since the XYZ color space is different from that of the RGB color space.

My question is, do you know what are the range of values for each of the X, Y, Z parameters? I can't find this in the existing documentation. I was thinking of checking the range of values by trial and error (changing one parameter and seeing whether the values are clipped by comparing the results visually), but I hope there's a better way to do this or that there was some documentation that I missed.

Note: The online EasyRGB calculator limits the X, Y, Z parameters from 0 to 95.047, 0 to 100, 0 to 108.883 respectively, and I'm suspecting that the limits for Mathematica would be simply 1/100 of these limits. Would like some verification on this if possible, though.

share|improve this question
    
Somehow my pictures are not loading. I'll try my best to get them up, but it should be understandable without. –  Vincent Tjeng Mar 26 '13 at 5:04
    
I believe this will be improved in a future version. –  Matthias Odisio Apr 1 '13 at 19:46
    
@MatthiasOdisio I don't see why you added the "bugs" tag. There were no bugs reported at all. Not by the OP and neither in the answers. I removed the tag. –  Sjoerd C. de Vries Apr 13 '13 at 17:49
    
@SjoerdC.deVries I believe the current behavior is not as exact as it should; that's why I re-tagged. This question is on my radar and I'll post an answer when there is an update in the situation. –  Matthias Odisio Apr 15 '13 at 13:54
    
@MatthiasOdisio Please note that the "bugs" tag may only be used for bugs confirmed either by Wolfram Inc, or a sufficient sample of the community. See the tag-wiki of the "bugs" tag. –  Sjoerd C. de Vries Apr 15 '13 at 14:09

3 Answers 3

up vote 6 down vote accepted

I believe you are correct. To see why, build an image that's random, but stick a pure white pixel in the {1,1} location:

imgData = RandomReal[{0, 1}, {10, 10, 3}];
imgData[[1, 1]] = {1., 1., 1.};

You can view the image with Image[imgData]. Now convert this to XYZ:

ColorConvert[Image[img], "XYZ"]

and look at the new image data using

ImageData[ColorConvert[Image[img], "XYZ"]]

The {1,1} element is now:

{0.950428, 1., 1.0889}

which is what you expected from the EASYRGBCalculator.

share|improve this answer
    
thanks! I think you're right. I'm just delaying accepting your answer in the hope that someone who knows where to find the documentation will come around, but thank you for your reply! –  Vincent Tjeng Mar 26 '13 at 13:59

For those interested in this question, I finally received a reply from Wolfram support.

The email I received was as follows:

... I have been trying to get a confirmation of what values are used by Mathematica. All my tests show the values used are the same as in other color functions in Mathematica, that is we restrict values to the (0, 1) interval. Negative values are understood as 0 and those above 1 are treated as 1. ...

share|improve this answer
1  
What do you think about this response? It seems incorrect to me, because explicitly clipping the Z value of 1.0889 (per bill s's answer) to 1.0 and then converting back to RGB gives a different result than leaving it unchanged. Namely, the RGB coordinates for the XYZ value {0.950428, 1., 1.} are {1., 0.996307, 0.90602}, which is clearly different from {1., 1., 1.}. I am sure WRI support try their best but unfortunately it is not at all unknown for them to give misleading or simply wrong answers. –  Oleksandr R. Apr 15 '13 at 13:05
1  
@OleksandrR. I believe that the answers given above were correct, and for my work I will continue using the X Y Z ranges suggested by Bill S. –  Vincent Tjeng Apr 16 '13 at 2:04
    
{1., 1., 1.} is definitely crap –  adrienlucca.wordpress.com Aug 11 '13 at 18:43

The maximal values {0.950428, 1., 1.0889} are the reference white point of the D65 illuminant for a perfect diffusor (an object which diffuses incoming light randomly in every direction)

The middle value 1 simply means that 100% of the light is diffused (0% absorption)

I dont think the values XYZ have a maximal range, but X and Z can never be equal to 0. The values of X and Z are proportionnal to Y, and Y usually varies between 0 and 100, but can exceed 100 in the case of fluorescent colors, or direct reflections for ex.

So don't assign maximal values to X and Z

The EasyRGB calculator gives the values {0.950428, 1., 1.0889} for a D65 illuminant, if you change to another one (A, C, D50, etc.) you will get other sets of XYZ for white at L*C*h° = 100, 0, 0

If you want to simulate multi-illuminant situations, a limited range for X and Z might cause problems.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.