Jump to content
Science Forums

Color Hues Converted To A Frequency?


7DSUSYstrings

Recommended Posts

Instead of reinventing this wheel, assuming it already exists, I'll put this to those who are better at math than I am. Are there any routines out there for converting RGB data to a wavelength? There might even be a coded routine for this. I still use Delphi7 so Pascal would be nice, but simply a mathematical routine I could use with a calculator would be helpful.

 

Thanx

 

Dr. C.

Link to comment
Share on other sites

Are there any routines out there for converting RGB data to a wavelength?

Strictly speaking, it can’t, by definition, be done, because a given RGB color per a specific color space definition may consist of colors of a mixture of colors of at least 3 pure monochrome colors.

 

For example, a specific RGB color model using monochrome primary colors might define R as having a spectrum (usually called chromaticity in color models) with a all its frequencies at exactly 450,000,000,000,000 cycles/second (450 THz), G at 550 THz, and B at 650. Mixed together in some usual way, the resulting spectrum would have peaks of different relative size at each these frequencies.

 

In practice, none of the standard RGB color spaces use monochrome primaries, so spectrum of the light they produce is spread out, not peaked at 3 frequencies.

 

I think, though, that what Dr. C is really asking is something like "what single frequency would be indistinguishable by typical human from a single color produced by a perfect rendering device given GGB 3-number color value?"

 

For starters, a indistinguishable-from monochrome color doesn’t exist for all possible colors of a given RGB color space, only for the very “densely saturated” ones. Any color approaching a “shade of white” doesn’t correspond to a monochrome color – that is, there’s no such thing as “a photon of white light” or “the frequency of white light”.

 

For those saturated colors that do look like – that is, fool our eyes into perceiving them as - monochrome light, while I suspect we might be able to write some formula, beginning with empirical data on the response of the major photosensitive nerves in our eyes’ retinas to different pure light sources, I’m unaware of this having actually been done and such a formula published. Someone else might know, or be able to research, this better than me.

 

Since most of what we look at aren’t pure monochrome colors, most work on artificially reproducing colors have focused on other than producing them. It’s not easy to produce a specific nearly-monochrome color. You have to essentially engineer something, such as a glowing single element solid or gas, or a tunable laser. I’m unsure if such devices exist for single frequencies in the visible range.

Link to comment
Share on other sites

I understand what you are saying and pretty much had considered most of that. I think what might be an approach is to find an average. The problem is we can have different sets of 3 numbers, per se, that could average to the same quantity. I may have to be satisfied with using (or creating a new) catalog system, for instance Pantone shades have formulas that involve a number of primary ink shades and are assigned a code. Now, of course, we have true color containing hue and saturation versus cmyBk and multi-color professional printers. 64 million colors allows us a very fine mesh of choices.

 

I'll need to look at all my various compilers to see what each offers, if they do, a converter. It seems as though I ran across one, but am not certain...

 

thank you

Link to comment
Share on other sites

I'll need to look at all my various compilers to see what each offers, if they do, a converter. It seems as though I ran across one, but am not certain...

I’m very curious (and sure I’m not the only one) to know what you find, Dr C, so please do share when you’ve finished searching. :thumbs_up

 

Purposefully seeking to reinvent the wheel – a serious personality flaw of mine I’ve been told, and agree, as I tend to prefer re-inventing to re-using :) – I think the inverse of the R,G,B -> f algorithm we seek, f -> R,G,B can be arrived at pretty directly:

 

Take the measured responsivity data for the main color-sensitive photoreceptor cells in the human eye: the S, M, L (Small, Medium, Large) cones, corresponding to the primary colors B, G, and R (Blue, Green, Red).

 

Given a particular frequency (or inverse wavelength) value f, find the 3 responsivity values R,G,B

 

An example sketch:

post-1347-0-29844200-1334165102_thumb.jpg

Here a c/f = 475 nm monochrome color maps to the RGB value (0.11, 0.2, 0.48)

 

Sketches like this also illustrate the impossibility of an exact R,G,B -> f algorithm. Consider a “bright white” RGB value of (1,1,1). There’s no vertical line that can be sketched to intersect the 3 responsivity curves to at these values.

 

Most RGB values can't be exactly mapped to monochrome f values. The collection of possible RGB values corresponding to pure monochrome light is much smaller than the collection of all possible RGB values corresponding to more spread-out spectra.

Link to comment
Share on other sites

http://www.fourmilab.ch/documents/specrend/

 

A quick Bing search brought up this. I'm going to look at Pantone as well. The link here, though, does include a link to some code in C.

 

I appreciate the attention to this. My day is often so busy that it's tough to get too organized, where some of you dudes and dudettes just might have more contiguous time to devote to such a curiosity.

 

Isn't this fascinating though? In case you are wondering why I'm wanting this, it is to help with analyzing the various picture elements of that DG Tau B Hubble image in another post about the universe. As of now RGB values seem to indicate the fringes are composed of light from either outer light sources, or they are internally generated, as opposed to being illuminated by the plasma jets.

 

I'll check my D7 library in a little while.

 

Thanx again

Link to comment
Share on other sites

EBasic had the one I remembered. It takes the RGB values and converts them to 0 to 255, but that's not true color. I went to Coding Monkeys site and queried the IWB authors about this in Ionic Wind Basic, which EBasic evolved into. If anything, this tends to suggest it can be done...

 

I asked him for some code snippets, but that's like trying to get a bossy blond gal to let you eat freely from her bag of marshmallows... :D

Link to comment
Share on other sites

The lightbulb comes on... (hopefully not like it did for Bob Goldthwaite in "Hot to Trot..." :D )

 

Looking at that average and the myriads of possibilities of frequencies that could reduce to the same number, an uncommon factor would be needed to generate the different position in the spectrum. This might be possible by comparing the phase relationship of the phase angles and time variance to give a common wave length.

 

Say we have 0,50,100 or 50,50,50. Both would average to 50, but 50,50,50 would have one phase relationship/time variance, where 0,50,100 would have another, assuming time is measured peak to peak, since a trough could have many interstices along the spectrum. Half the wavelength at 0 amplitude would give us an angle related to one or the other wave positions at peak amplitude.

 

I came up with this from considering CraigD's sketch of the wave relationships...

Link to comment
Share on other sites

I’m worried that some confusion and misunderstanding is happening here. :(

 

Looking at that average and the myriads of possibilities of frequencies that could reduce to the same number, an uncommon factor would be needed to generate the different position in the spectrum. This might be possible by comparing the phase relationship of the phase angles and time variance to give a common wave length.

...

I came up with this from considering CraigD's sketch of the wave relationships...

The curved shapes in my sketch look somewhat like halves of 3 different sinusoidal waves of different lengths and phase, but aren’t. They’re simply a graph of the optical responsivity of 3 kinds of retinal cone cells (follow this link to see where I stole the background for my sketch from :)) to different light at different frequencies – that is, how often a large collection of such cells fire when struck by a shower of photons of a specific wavelength (or, inversely, frequency). The similar look of these graphs to a wave is mere coincidence.

 

Say we have 0,50,100 or 50,50,50. Both would average to 50, but 50,50,50 would have one phase relationship/time variance, where 0,50,100 would have another, assuming time is measured peak to peak, since a trough could have many interstices along the spectrum. Half the wavelength at 0 amplitude would give us an angle related to one or the other wave positions at peak amplitude.

I don’t understand what you mean about angles, and as I say above, think your references to phase and time come from misinterpreting my sketch.

 

The 2 RGB values you give describe very different colors. Assuming you’re values are in the range 0 to 100, they render and normalize (dividing by 100 so they’re in the range 0 to 1), to this:

post-1347-0-72738700-1334216743_thumb.jpg

Notice that RGB values where the 3 numbers are equal are “greyscale” colors, from (0,0,0) for dark black to (1,1,1) for bright white. (0.5,0.5,0.5) is “middle gray”.

 

The key idea in chromatics – Newton’s big 1675 “Hypothesis of Light” breakthrough – is that what we perceive as light of a single color are practically always actually a mixture of light of many colors, known as a spectrum.

 

Conveniently, our eyes perceive many different spectra as the same, making it possible for 3-color-emitting devices like computer displays, or paint and ink on various surfaces, to appear to be almost anything we can see from any natural source. If our eyes were different – say, had prism-like lenses to spread the colors of a spectrum over an array of black-and-white sensitive rod cells, making them essentially biological spectrograph – it would be much harder for printers, painters, and electrical engineers to produce images!

 

Let’s not over-complicate spectography, which is simpler, IMHO, than trichromatic color schemes, human perception, paint making, etc.

 

It’s not difficult to record precisely what a given light source is emitting: just capture its spectrum. A spectrum can be represented with arbitrary precision simply by counting the number of photons of several ranges of wavelengths over a given period of time, which can be done using something as simple as a triangular glass prism and photographic film. But you can’t represent one as single wavelength or frequency number, any more than you can describe the contents of a bag of M&Ms with the name of a single color. You’ve got to, essentially, count and make a histogram of what you’ve got, be they photons falling within various range of frequencies, or candies of various colors.

Link to comment
Share on other sites

don’t understand what you mean about angles, and as I say above, think your references to phase and time come from misinterpreting my sketch.

 

 

Actually, I am right with you and even know about responsivity (imagine that :) ). What happened is your sketch "triggered" the idea from electronics. Yes, as Newton demonstrated, color is polychromatic. Nonetheless there will be the individual wave components and, as they would appear on the chromograph, they will have phase relationships, including phase angle relationships, deeply integral in the sinusoidal waveform, say versus the triangular or square waveforms that tend to be more incremental. A phase relationship can have more than one meaning and in this case, once again triggered by your sketch, I proposed we could establish a difference between averages by including the slope from the position at 180 degrees to the position of the next crest position on that chromagraph's peak or crest. We could even use XY relationships, just as if we were mapping the output from an oscilloscope.

 

Am I communicating this any better for you? :)

Edited by 7DSUSYstrings
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...