Convert frequency to RGB

Joel Rees joel at alpsgiken.gr.jp
Mon Aug 11 21:32:00 EDT 2003


Dar Scott <dsc at swcp.com> writes:
> 
> On Monday, August 11, 2003, at 05:10 PM, Monte Goulding wrote:
> 
> > Ideally if it were to be in libColor I'd like a WavelengthToRGB 
> > function and
> > an RGBToWavelength function.
> 
> In general, you can't do an RGBToWavelength.

This thread reminds me of when I was in high school and we built an RC
oscillator with a pot, and I did the natural thing and tried to
extrapolate the concept to the visible spectrum. I kind of bleeped over
the transponder problem, because I figured, hey, light is
electromagnetic radiation. One loose wire makes a good antenna, right?

> Wavelength is 1D and color without brightness is 2D.  RGB is 3D. We 
> see a rich range of colors by a mix of more than one wavelength of 
> various intensities. 

And when we adjust any single RGB output value, we end up adjusting the
output in each of the 3 dimensions. That's part of the reason we have
RGB, CMYK, and several other color spaces, and it's also why values in
each color space don't correspond exactly, isn't it?

> A large part of that space we see can be 
> replicated by the right mix of red, green and blue phosphors (each of 
> which is really a mix of several wavelengths, muddying colors a tiny 
> bit, but looking great anyway).

Darn those non-ideal transponders!

> As for WavelengthToRGB, the CEI tables convert to non-real RGB-like 
> values that are related to physiological and psychological response.  
> This could be handy.  However, these are not the same as the typical 
> phosphors including those defined for monitors, such as VGA. 

And I guess it goes without saying that no two tubes are exactly alike.

> Those 
> colors are inside the space of observable colors and form a triangle of 
> possible RGB colors. 

And IIRC, that triangle varies, even from tube to tube of the same model
CRT from the same manufacturer, manufactured in the same batch.

> The wavelengths run along the periphery of 
> observable colors--outside of that triangle. 

And I'm thinking to myself, that's never really hit me before.

> That means all 
> wavelengthToRGB calculations must be compromises.  The colors are 
> _always_ wrong.  One model for compromising is to select the best color 
> along the edge of the RGB color triangle.  Then you have the problem of 
> what best means.  I like the idea of where a line from white to the 
> desired color crosses the boundary of the RGB color triangle.  However, 
> I suspect there is probably a better way to do this by whitening all 
> colors, that is by shrinking the CEI color horseshoe into the RGB 
> triangle.  The psychologists can say better than I.  All this to say 
> that a WavelengthToRGB function can be handy and valuable, but must 
> either be spec'd carefully or described as approximate. 

Shouldn't we say, "described as approximate, no matter how carefully we
spec it?" ;-(

> The one that 
> Jim is tinkering with is definitely the later, but might be useful to 
> him and to others.
> 
> Dar Scott

I once knew enough math and physics that I might have had a hope of
setting up a set of differential equations to describe the effective
wavelength and intensity, combining three inputs of constant wavelength
at varying intensities. If you had that, you could just hold the
effective intensity constant and solve the inputs for the effective
frequency, then vary the effective frequency continuously through the
visible spectrum. Now that I understand what it means, I don't remember
the math or the physics. 

Anyway, it sounds like a good masters thesis project in physics.
It has probably been done, maybe more than once, considering the number
of assumptions and approximations that have to be chosen along the way.
If you could find such a thesis, implement the numerical approximations
in C or ForTran, and store the resultant list of RGB values into an
array, you might or might not have a pretty good simulation table.

(Calculating the series at run time in Revolution would be an
interesting puzzle, too.)

I think, I might be rather inclined to just take the suggestion of going
and getting a large image of a natural rainbow, taking a cross-section
sample of the colors, and storing the RGB values from that cross section
into an array of constants that you just scan through.

-- 
Joel Rees, programmer, Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp




More information about the use-livecode mailing list