Is it possible to calculate the color frequency of a pixel?

I mean, I get a pixel that is red but where this red sits on the spectrum in hertz?

Is this even possible to do even in a limited way?



3 Answers 3


Yes, but the answer is a little more complicated than you were probably hoping for.

In short: one color in general corresponds to a distribution of different frequencies, or wavelengths.

You have three types of cone cells in your eyes [+ one type of rod cell]. Color-blind people have less than three types (or their response curves are closer together). It is believed a few people may exist, "tetrachromats", who have four types. Some species of octopi see in 11 dimensions of color.

Spectral sensitivity curves

Each type of cone cell is sensitive to certain wavelengths. If you have two lasers, you can draw a vertical line from the frequency of the laser up to each spectral response curve and add the values for each cone type to get the total "stimulus" per type. It is clear then that you can have a vast combination of frequency pairs that cause the same stimulus in each of the S, M, and L type cells! This is why a computer monitor can generate the color yellow using red and green subpixels. This same yellow can occur with photons of one wavelength that give the same total stimulus.

So the phenomenon of color isn't as simple as matching each one up to a wavelength. In fact, there are colors that humans can see that correspond to no single wavelength! No laser can produce the colors pink and purple.

Below is a chromaticity diagram. I won't go into too much detail about how this is constructed, but it roughly corresponds to all the types of colors you can see. You can also vary the luminance of the diagram (roughly corresponds to the illy-defined term "brightness").

CIE 1931 Chromaticity Diagram

Anyway, this diagram has a few interesting properties.

  • While it represents all of the colors you can see, all of those colors are not actually displayed on your screen. This is because for multiple light sources, you can only reproduce the colors that are within the vertices of the polygon formed by connecting the corresponding chromaticities of each light source. Most monitors use three primaries (approximately red, green, and blue) and so these monitors can only reproduce the colors within a triangle. Note that the area of the triangle does not correspond to anything particularly meaningful. The diagram is not designed to give equal space between distinguishable colors.
  • The only way you can actually reproduce all colors that a human can see is with two tunable lasers. This is possible by splitting light from a blackbody radiation source (e.g. the sun) using a prism, passing the light through a narrow frequency filter, and mixing it with light from another prism of a different wavelength.
  • The edge of the diagram (the smooth curve) corresponds to the wavelength of light.

Now, with this background, I can answer your question a little more directly. Since monitors use three light sources per pixel, the nature of each subpixel's light must be characterized with its own spectral power distribution. For most purposes this can be approximated as a single wavelength. You then have to determine the three coefficients that weight each subpixel such that the sum of their values times the corresponding intensities on the stimulus response curve equals the same as which produces whatever color it is you're wondering about. Most color primaries data is freely available online, but I'll leave the math problem for someone else.

  • $\begingroup$ Altered someone's edit to my post. We are not "RGB-seeing" humans, as I thought I had presented clearly enough. We have three types of cone cells that sense different wavelengths. For tetrachromats and color-blind people, this doesn't correspond to RGB! $\endgroup$
    – Nick
    Commented Mar 24, 2013 at 21:16

Each pixel on a typical computer monitor is actually made up of 3 subpixels that are of a single, fixed frequency. The control circuitry of the monitor adjusts the brightness of these three subpixels in order to feed light to your eye that your brain interprets as lying somewhere on the visible light spectrum.

The answers to nearly the same questions are available here.


What about just taking frequency ranges given on the Wikipedia article on color and pairing them with the hex codes for the background colors they subimpose? This would be a stepped function, but you could always make it piecewise linear, or approximate it with a bezier or some sort of basis function expansion.

Also, this would certainly have trouble being represented evenly across displays. Perhaps someone who understands color gamuts better could explain exactly what we mean by FF0000? The peaks in the plot of responses of different cone cells given by Nick are at 420–440 nm for S, 530–540 nmf for M, and 560–580 nm for L (tristimulus values), which I think sRGB then somehow links to red, green, and blue values through a 3x3 matrix of some magic numbers.

You might be able to use those peak center locations to bang out a different first approximation than the one from the Wikipedia list of color frequencies. Then do a weighted average of the two methods! This is real science.

Edit: Ok, it looks like I ignored the real problem--we need $f:\mathbb{R}^3 \rightarrow\mathbb{R}^1$ to take us from RGB to frequency space! And apparently taking a linear combination of the three primaries won't cut it.

Another problem is that natural light isn't just a single frequency--it's a spectrum (which you could liken to a probability distribution $P(\lambda)$). So, I lied with that earlier function description. Natural light isn't really $\mathbb{R}^1$--it's actually more like $\mathbb{R}^{60}$, for a 5 nm discretization of a 300 nm range. This is converted to $X$, $Y$, and $Z$ by convolving this discretized spectrum of natural light with the three CIE color matching spectra $Q_i(\lambda)$(see equation 1) (that is, taking the inner product).

Then you can convert the $X$, $Y$, and $Z$ to $x$, $y$, and $z$ by normalizing them by their sum (equation 2), and then then convert them to RGB using those sRGB magic numbers (equation 3). Further shenanigans with a white point are required to represent (approximate?) out-of-gamut colors.

This is great for converting a known spectrum to a particular RGB triad, but I'm not sure how to go the other way. I guess you'd want to create a normal distribution $P(\lambda)$ such that the process I just described gets you the desired RGB triad, and you would find this $P(\lambda)$ through some sort of optimization problem? Then the "single frequency" would be the mean of this distribution? This is quickly getting to be very computationally expensive.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.