5
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ Somehow my pictures are not loading. I'll try my best to get them up, but it should be understandable without. $\endgroup$ Mar 26, 2013 at 5:04
  • $\begingroup$ I believe this will be improved in a future version. $\endgroup$ Apr 1, 2013 at 19:46
  • $\begingroup$ @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. $\endgroup$ Apr 13, 2013 at 17:49
  • 1
    $\begingroup$ @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. $\endgroup$ Apr 15, 2013 at 13:54
  • $\begingroup$ @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. $\endgroup$ Apr 15, 2013 at 14:09

3 Answers 3

6
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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! $\endgroup$ Mar 26, 2013 at 13:59
4
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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. ...

$\endgroup$
3
  • 1
    $\begingroup$ 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. $\endgroup$ Apr 15, 2013 at 13:05
  • 1
    $\begingroup$ @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. $\endgroup$ Apr 16, 2013 at 2:04
  • $\begingroup$ {1., 1., 1.} is definitely crap $\endgroup$ Aug 11, 2013 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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