Is it possible to obtain the light frequency of a colour from a RGB representation? I've found the opposite process [1] but I don't know if it's possible this way.
相关问题
- Finding k smallest elements in a min heap - worst-
- Why shouldn't I use pixels as unit with Box2D?
- binary search tree path list
- High cost encryption but less cost decryption
- DBGrid - How to set an individual background color
相关文章
- What are the problems associated to Best First Sea
- Coin change DP solution to keep track of coins
- Algorithm for partially filling a polygonal mesh
- Emacs/xterm color annoyance on Linux
- Robust polygon normal calculation
- Algorithm for maximizing coverage of rectangular a
- matplotlib bwr-colormap, always centered on zero
- How to measure complexity of a string?
Maybe Javascript - Sort rgb values can help you.
But the problem is that the wavelength spectrum looks like
And you can convert RGB to HSL, but HSL spectrum looks like
Then, there are problems because wavelength spectrum doesn't have all colors, such as pink.
I guess that's because pink doesn't exist in the nature, it's a combination of the colors of the opposite extremes of light's spectrum. But we have it in RGB.
AFAIK, there is no direct answer because multiple wavelengths can combine to give the same color right? So you have the wavelengths that map to pure colors and then their combinations can give many other and the same colors. And there are several combinations that can give the same color. This is because of inteference. So you essentially are asking for a one to many mapping.
To answer your question: There is no fixed formula. The reverse formulas will give you a range. That is the best it can get.
Looking at the C program that your link refers to, there are color_match values for only 81 different frequencies - these seem to be the labelled frequencies around the edge of Figure 3 in your link. So if you know that your RGB info is for pure light of one frequency, you could work out the RGB info for each of these values and see which it matches most closely - probably after scaling one or the other so that the brightnesses match.
The problem, of course, is that your RGB value might be from a mixture of light at different frequencies. In this case you will get a point that comes from the interior of figure 3 - it won't be close to any of the values around the outside (so at least you will be able to tell that there is a problem) and there will be a large number of possible sets of frequencies that could have produced it - these corresponds to weighted averages of points on the outside of the diagram that average out to produce your point on the interior.