4

I have the following spectrum (tabulated as {wavelength, power}):

spectrum = {{400, 0.16196`}, {403, 0.14969`}, {406, 0.1379`}, {409, 
    0.12663`}, {412, 0.11589`}, {415, 0.10572`}, {418, 
    0.096116`}, {421, 0.087105`}, {424, 0.078697`}, {427, 
    0.070899`}, {430, 0.063719`}, {433, 0.057158`}, {436, 
    0.051218`}, {439, 0.045896`}, {442, 0.041186`}, {445, 
    0.037081`}, {448, 0.033571`}, {451, 0.030643`}, {454, 
    0.028284`}, {457, 0.026477`}, {460, 0.025205`}, {463, 
    0.024449`}, {466, 0.024189`}, {469, 0.024404`}, {472, 
    0.025072`}, {475, 0.026171`}, {478, 0.027679`}, {481, 
    0.029572`}, {484, 0.031828`}, {487, 0.034423`}, {490, 
    0.037336`}, {493, 0.040544`}, {496, 0.044025`}, {499, 
    0.047758`}, {502, 0.051722`}, {505, 0.055897`}, {508, 
    0.060264`}, {511, 0.064804`}, {514, 0.069499`}, {517, 
    0.074333`}, {520, 0.079289`}, {523, 0.084352`}, {526, 
    0.089507`}, {529, 0.094741`}, {532, 0.10004`}, {535, 
    0.10539`}, {538, 0.11079`}, {541, 0.11621`}, {544, 
    0.12166`}, {547, 0.12712`}, {550, 0.13259`}, {553, 
    0.13805`}, {556, 0.1435`}, {559, 0.14893`}, {562, 0.15433`}, {565,
     0.15971`}, {568, 0.16505`}, {571, 0.17035`}, {574, 
    0.17561`}, {577, 0.18082`}, {580, 0.18598`}, {583, 
    0.19109`}, {586, 0.19613`}, {589, 0.20112`}, {592, 
    0.20605`}, {595, 0.21091`}, {598, 0.21571`}, {601, 
    0.22044`}, {604, 0.22511`}, {607, 0.22971`}, {610, 
    0.23423`}, {613, 0.23869`}, {616, 0.24308`}, {619, 
    0.24739`}, {622, 0.25164`}, {625, 0.25582`}, {628, 
    0.25992`}, {631, 0.26395`}, {634, 0.26792`}, {637, 
    0.27181`}, {640, 0.27564`}, {643, 0.27939`}, {646, 
    0.28308`}, {649, 0.2867`}, {652, 0.29025`}, {655, 0.29374`}, {658,
     0.29716`}, {661, 0.30051`}, {664, 0.3038`}, {667, 
    0.30703`}, {670, 0.31019`}, {673, 0.3133`}, {676, 0.31634`}, {679,
     0.31932`}, {682, 0.32224`}, {685, 0.32511`}, {688, 
    0.32791`}, {691, 0.33066`}, {694, 0.33336`}, {697, 0.336`}, {700, 
    0.33858`}};

How can I calculate the perceived color using Mathematica?

This is how the spectrum looks like:

Show[ListPlot[spectrum, Joined -> True], 
 AxesLabel -> {HoldForm[wavelength nm], HoldForm[power]}, 
 PlotLabel -> HoldForm[Spectrum], 
 LabelStyle -> {FontFamily -> "Arial Rounded MT Bold", 12, 
   GrayLevel[0], Bold}]

enter image description here

Can someone show me how to use this answer here: Convert spectral distribution to RGB color for my spectrum? I don't really understand how to do it.

james
  • 3,043
  • 13
  • 29
  • Read about `ColorData["VisibleSpectrum"] in the documentation, unless you want to use colorimetric calculations... – José Antonio Díaz Navas Apr 05 '18 at 13:15
  • You don't need Show. You can put all plot specification in you ListPlot – OkkesDulgerci Apr 05 '18 at 13:36
  • Oh, I am understanding what you want. Well, you need to get the tabulated data corresponding to the color matching functions (CMF) corresponding to a standard observer (CIE 1931 or CIE 1964), and calculate the tristimulus values $(X,Y,Z)$, and from these, the chromaticity coordinates...It seems to me that the perceived color will be likely orange..., but we will see after calculations... – José Antonio Díaz Navas Apr 05 '18 at 13:53
  • @JoséAntonioDiazNavas Yes, exactly. Would you mind to show me how to do it ? – james Apr 05 '18 at 14:25
  • Read carefully the link provided by @corey979... – José Antonio Díaz Navas Apr 05 '18 at 15:18
  • In this case, you need to resample with Interpolation[], since the built-in CMF table does not match with the tabulated wavelengths in your spectrum. With that, you can then do it like in my answer. I get approximately XYZColor[1.27381, 1.02122, 0.222] as the result, which is indeed a bit orange-y as @José says. – J. M.'s missing motivation Apr 11 '18 at 12:37
  • @J.M. Thank you very much. I created the interpolation (specInterpolate = Interpolation[spectrum]), but then I don't see how to integrate it into your answer. Would you mind to show me how you did it? – james Apr 12 '18 at 05:39
  • @J.M. Also, do you know, if the color intensity or brightness is included your model? I am asking because my spectrum is quite low in reflection intensity, yet XYZColor[1.27381, 1.02122, 0.222] looks quite bright to me. – james Apr 12 '18 at 05:42

0 Answers0