Spectrum to RGB color theory mixing question

Started by
5 comments, last by ptroen 14 years, 6 months ago
I'm prototyping a Spetrum to RGB renderer and I have the spectrum converted to RGB and can pick any color in the spectrum. This is good. However I have a small problem. Now that I have internally Spectrum I can render primary spectrum colors ok(blue,violet,green,yellow,red,reddish brown) but I don't have MIXING of colors. So I need to pick a method to mix the emission colors together but here's the dilemma the documentation(wikipedia/google) I've been trying to read is kinda sketchy. What I want todo is take say a emmision spectrum that may have 10-100 lines and then add up all the lines to form my resultant color through a "? method". Note I can't just add up the emmision lines on the spectrum directly because then I ignore white(which mixes all colors together in rgb space). Similarly pink is a similar case to white. Currently because I'm prototyping in .net it's relatively easy to just mix and match code for prototyping but I'm still at a loss which to go FOR THE ACTUAL SPECTRA to one RGB value. I do notice HSV and HSL articles but they talk about making the color conversation from RGB space and aren't exactly clear how spectra would be encoded since their represented as a color wheel? Can anyone enlighten me on my color ignorance ;-)
Advertisement
O wait nm. I think I got it. White is in RGB everything turned on and ditto for the spectrum. Also if I understand correctly in a spectrum their is more then one white because their are many more colors represented and thus more ways to mix the same color. So greyish is really just less white and magenta is purple+red? So yeah I think I can just dump it into a long int array and then process every line that's emmision and put in one rgb value.

Hopefully will look purity in a compute shader but for now must see if it technique feasible in .net app. Anyways if any more color insights that be appreciated. Thanks! :-)
If you have a function that maps frequency to RGB components, you can map an entire spectrum to RGB by integrating it. So if you have a few discrete lines in the spectrum, treat them as delta functions and the integral becomes the sum of their contributions. Notice that you may also have a continuous spectrum, like sunlight, in which case the integral is not exactly a finite sum (although it can still be approximated that way).

This makes me wonder: Would this give a principled way to convert from (something like, but not) HSV to RGB? Treat the color as a Gaussian distribution in the spectrum; hue is mean, saturation is variance, and brightness is the probability mass... Is this reasonable? Is anybody aware of a color model that works at all like this?

(EDIT: Actually, this may be a silly question; I'm checking out the CIE color model now; it's been a while since I've looked at it...)

(EDIT 2: Those conversions are all ugly and piecewise like I remember, which makes me actually wonder about this "simple" Gaussian idea... I shall play with this and see how well it matches what I normally think of as "hue," etc...)

(EDIT 3: But then how can you get violet if, as you shift the mean to the left, you only activate blue receptors? This doesn't give the desired cyclic property... unless (:-)): The retina is a discrete-time system, and high frequencies get aliased down to low frequencies; this would give the desired cyclic behavior. Holy shit; is this how it works?!)

(EDIT4: No, that doesn't make any sense physically. It's really best explained just by that low-frequency "bump" that the red receptors happen to have...)

(EDIT5: No, that too is wrong... That bump only exists in CIE XYZ, not CIE RGB; in CIE RGB there's actually a negative bump.)

[Edited by - Emergent on October 14, 2009 1:52:21 PM]
I suggest taking a look at CIE Luv. The conversion to/from RGB is cheaper than HSV/HSL and LAB.
Quote:Original post by patw
I suggest taking a look at CIE Luv. The conversion to/from RGB is cheaper than HSV/HSL and LAB.


Thanks.

I do find all this CIE stuff confusing. Human perception is messy.

What would make much more sense to me is a description in terms of power spectral density functions and absorption spectra of S,M, and L cones. Then "true" color is a point in a Hilbert space; we only perceive this point's projection onto the 3d subspace spanned by the S,M, and L responses. Then a trichromatic light source can output any point in the Hilbert space spanned by the power spectral density functions of its red, green, and blue light sources, which is a different 3d subspace of the Hilbert space. Presumably these two subspaces intersect only in a 2d subspace, which is itself interesting. But in any event, if you want to produce a given S,M,L color, you just need to find the point on the subspace spanned by the R,G,B power spectra which projects to the correct S,M,L point -- which is a simple geometry problem... And it's all linear... which means that the fact that humans apparently find this nonlinear "hue" function important bothers me...
oh right INTEGRATION! :-)

Now need to dust off my rusty calculas :-) time to plot out the function and solve by paper. Thanks!!!!!

This topic is closed to new replies.

Advertisement