Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Colour (RGB/HSV/HSL) to wavelength.

  1. Aug 2, 2010 #1
    I've been searching on this topic for the past 10 minutes and then realised it'll be better just asking someone about it. Anyway yeah, the question is, are there any specific equations that will give me the wavelength when I give it the colour values? I saw some sites where each colour in the rainbow was assigned a frequency. But I want to use RGB. Any suggestions?

  2. jcsd
  3. Aug 2, 2010 #2
    google: color value to wavelength
    fourth link: http://www.filebuzz.com/findsoftware/Wavelength_Color/1.html
    Might be what you want. But some of the other links look interesting too.

    However there are "non-spectral" colors, e.g. magenta, that are artifacts of the eye sensor's construction so some RGB values don't have a physical embodiment.
  4. Aug 2, 2010 #3
    You can get the color of a given wavelength (more precisely, of a narrow spectrum centered on a single wavelength), but going the other way is not generally possible. Probably the best way to approach this would be to build a table of RGB values for visible wavelengths, then find the closest match to your given color, and report the wavelength and how close it was. You might do this more efficiently by concentrating on the hue.
  5. Aug 2, 2010 #4
    In general, the colors we typically see include many wavelengths. Colors with single wavelengths are special cases.
  6. Aug 2, 2010 #5
    Hmm okay I'll give this a shot and like Dr Lotts o'Watts said, colours are of many wavelengths I guess, stupid of me to forget it. So basically if I use this method it means that it wont be that accurate. Though, if I calculate similarity based on distances on a RGB cube it might still be worth it.
  7. Aug 3, 2010 #6
    I don't understand why the RGB->wavelength transform wold not be reversible, aside from the non-spectral-color issue, accounting for all the weird-and-wonderful strangeness of non-linear eye response in brightness, etc?

    As to "colors containing many wavelengths"... It is possible for the eye to "see" a particular color in two ways, both of which involve excitation of particular cone sensors. One way is to tickle each sensor, say red and green, in just the right amount with two distinct wavelengths, so we "see" yellow. The other is to tickle the sensors by the same relative amounts with a single yellow wavelength. I think the latter is what the OP was getting at in doing the RGB conversion, yes?
  8. Aug 3, 2010 #7
    Wavelength implies monochromatic light, so it strictly only includes colors along the standard rainbow spectrum. Do you see any pastels on that spectrum? What is the wavelength of white light?
    If you are interested in the rigorous treatment of RGB color space and the human visual system, then you will end up becoming familiar with the CIE color space, which is a color model based on decomposing a given spectral distribution of wavelengths (i.e. a color) into a sum of three well-defined spectra corresponding to the spectral response of the 3 perception mechanisms in the human eye. The weights of these 3 curves are the CIE tristimulus values that express a color in CIE space. The process of converting an arbitrary distribution of visual wavelengths into an RGB color begins by integrating the spectrum with each of the tristimulus spectra to get a CIE color, then converting that to RGB given a certain definition of white.
  9. Aug 4, 2010 #8
    Thank you very much. I think I may have to use this.

    And schip666, it may be possible but very inaccurate.
  10. Aug 4, 2010 #9
    Ok,ok,ok.... conversion is reversible where it is possible at all then? Being an engineer at heart, I'll take what ever works.

    Thanks for the further info!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook