9

Do the "colors" form a 3-dimensional vector space?

Colors are just different frequencies of electromagnetic lights, from the low frequency (infra-red, red) to the high frequency (blue, purple, ultraviolet).

So using the value of frequency $f$ or the wavelength $\lambda$ to label the color is 1-dimensional: $$\lambda \in [400 nm, 700nm].$$

However, people usually use RGB or CMYK systems with 3 coordinates $$(r,g,b)$$ $$(c,m,y)$$ to label the colors. Hence the colors seem to live in a 3-dimensional vector space? But we need to define the addition between two vectors, and the multiplication on the vector, if that makes sense. More precisely, how are colors being labeled mathematically?

enter image description here

Qmechanic
  • 201,751
  • 8
    I’m voting to close this question because it is about the human visual system and not about physics. I think it has also been answered multiple times: The eye has three kinds of color receptors. – G. Smith Apr 01 '21 at 22:47
  • 1
    Colors can be made from a combination of frequencies instead of the perfect 1d single frequencies of monochromatic colors. – shai horowitz Apr 01 '21 at 22:47
  • 1
    https://en.wikipedia.org/wiki/Color – G. Smith Apr 01 '21 at 22:51
  • 1
    https://en.wikipedia.org/wiki/Trichromacy – G. Smith Apr 01 '21 at 22:52
  • RGB codes run between $(0,0,0)$ and $(255,255,255)$ at integer points so at best you could label the colours as a kind of "discrete sphere" of radius $r=255$, but not an entire vector space since $\Bbb R^3$ is not bounded in the right way. – Charlie Apr 01 '21 at 22:56
  • 1
    It's not a vector space—addition and multiplication doesn't work the way you need it to. However, it (the space of possible visual states, not just hues) is a 3-dimensional manifold (with boundary), diffeomorphic to the closed unit ball in $\mathbb{R}^3$, I believe. – thorimur Apr 01 '21 at 23:03
  • 5
    Also, importantly, colors are not different frequencies of light! Rather, they're combinations of stimulation levels of color receptors. For example, there is no monochromatic magenta. Many different frequencies of light can be incident on a given patch of the retina at once, and so the topology of hue-space is a circle (hence color circles), not an interval. – thorimur Apr 01 '21 at 23:04
  • 2
    @Charlie discretization of color space is an artifact of computer representation. Depending on color depth you can have $2^{24}$ colors (True color) or $2^{30}$ colors (Deep color) or even more. Moreover, in OpenGL any color is a triple of floats, which have even smaller (and non-even) spacing. – Ruslan Apr 01 '21 at 23:14
  • 5
    Just one remark that isn't addressed in the existing answers: light of a single wavelength/frequency (called monochromatic) indeed forms a one dimensional space (not a vector space) but it does not contain all colors. It contains the colors of the rainbow, but not for example white or brown. A distribution of intensifies of radiation of different wavelengths is called a spectrum. Many different spectra are perceived as having equal color, but most of them don't correspond to any color of the rainbow. – doetoe Apr 02 '21 at 07:18
  • 1
    Possible duplicates: https://physics.stackexchange.com/q/48224/2451 , https://physics.stackexchange.com/q/425649/2451 , https://physics.stackexchange.com/q/552840/2451 and links therein. – Qmechanic Apr 02 '21 at 09:28
  • I think Captain Disillusion has a video about this topic CD / Color. – Kripke Platek Apr 02 '21 at 10:19
  • It depends on whose eyes you're using. Most humans and most other primates are trichromats, so for them, yes. Most mammals and colorblind humans are dichromats, so for them it's a 2-dimensional space. Many birds are tetrachromats, so you'd need a 4-D space. (And various space probes & telescopes may have many more color channels - see "multi-spectral imaging".) Color is a matter of biology/technology. – jamesqf Apr 02 '21 at 16:49
  • 1
    @doetoe although metaphorically one can refer to spectral colors as "the colors of rainbow", physically it must be noted that actual rainbow colors are not pure. – Ruslan Apr 02 '21 at 18:01
  • I asked another https://physics.stackexchange.com/q/627174/42982 – ann marie cœur Apr 05 '21 at 13:20

7 Answers7

9

As What is Gray, from a physics POV? says, colors are only in the mind. Never the less, there is physics behind it, or at least color science.

While colors do form a 3D space of a sort, as thorimur's comment said, it is not a vector space. A vector space contains vectors that can be added together and multiplied by numbers. Let us talk about adding light by combining beams of colored light.

If red was a vector, $3*$red would be too. Also $100000*$red. This would mean a redder red, not a beam of light with more energy in it. There is a limit to how red things can get, because there is a maximum sensation your eye can generate.

Also there would be $0$ vector. Adding $0$ to any vector would leave the vector unchanged. It would have to be black, the absence of light. Given red, there would have to be a "negative red" that you could add to red to get $0$, or black. Light does not add this way.

Typically, mixing beams of light leads to white. See Can you create white light by combining cyan wavelengths (490-520nm) with red wavelengths (630-700nm)?. White is not the $0$ vector. It is more like the "biggest" color, the color you get by adding up all the others.

So it doesn't really work like a vector space. Never the less, color spaces have been invented, as the last link and Ruslan's answer describe.

mmesser314
  • 38,487
  • 5
  • 49
  • 129
  • 2
    3 × red is not redder: it's higher intensity red. The CIE XYZ color space behaves pretty much like a subset of a 3D vector space. C.f. the linear transformations used to get from (X, Y, Z) to (L, M, S) or the various (R, G, B). It's a subset because only the vectors with positive coordinates and within the visible gamut are real colors. The idea that more red is “redder” could only make sense if you think about chromaticities rather than colors. But chromaticities live in a 2D projective plane rather than a 3D vector space. – Edgar Bonet Apr 02 '21 at 12:05
  • @EdgarBonet - I guess that makes sense. A red light beam combined with another identical beam would produce a more intense beam of the same color. I will edit. – mmesser314 Apr 02 '21 at 17:40
8

Colors are just different frequencies of electromagnetic lights

If you follow this definition, you'll only ever get pure spectral colors, which your monitor isn't even able to display (unless it's a laser projection display). Going over spectral colors with one luminance, you'll only draw a one-dimensional curve in the whole visible color gamut.

the colors seem to live in a 3-dimensional vector space?

The set of all colors is normally not a vector space: it's more like a subset of a vector space, because there are limits to values of the color components. E.g. some values would yield imaginary colors, while others (too high) would simply destroy the retina. The latter is important because color is in principle a product of perception, and it doesn't make sense to abstract them from the limits of detectors.

But yes, the set of all* colors is well represented by a 3-dimensional space called color space. One of the most basic color spaces is the CIE 1931 color space, which is the base to derive other color spaces like RGB (with multiple varieties like CIE RGB, sRGB and others), CIELab and others.

The CIE 1931 color space allows to add the colors as vectors, yielding the color that one would get by mixing corresponding light sources. In others addition may be not as simple in meaning, e.g. due to nonlinear transfer function (sRGB), perceptual color distance function (CIELab), etc..


*There are caveats: in scotopic mode there's only one dimension—luminance—and its luminosity function differs from the photopic one. In between there's mesopic vision, where the color space is 4-dimensional, since rods and cones are active simultaneously.

Ruslan
  • 28,862
  • 2
    Re “_there's no natural way to define a scalar product of two colors_”: The existence of a scalar product is not a requirement for a vector space. It is only needed if you want to define an inner product space. – Edgar Bonet Apr 02 '21 at 12:20
  • @EdgarBonet oh, indeed. I mistook the definition in Wikipedia (which explicitly says that it's not to be mistaken :) ) where scalar multiplication is simply multiplication by a scalar... – Ruslan Apr 02 '21 at 12:32
  • A subspace of a vector space is a vector space. Maybe you meant a subset. – Dan Piponi Apr 02 '21 at 15:30
  • @DanPiponi hmm, does "subset of a space" make sense actually? A space isn't just a set to take a subset of... – Ruslan Apr 02 '21 at 17:51
  • @ruslan Yeah, to be strict I ought to say subset of the space of elements of a vector space but everyone sloppily identifies vector spaces with their sets of elements :) – Dan Piponi Apr 02 '21 at 18:29
  • Thanks again, the question can be reopened if we have one more upvote. – ann marie cœur Apr 03 '21 at 21:28
4

I'll put this in another way, perhaps it will help someone to finally grasp it.

THERE ARE NO COLORS

There are just rays of light of different frequencies. And there's an infinite variety of frequencies available.

Where colors appear are in our eyes and in our minds. In our eyes we have the photoreceptor cells, and our minds interpret the signals from these cells. Furthermore, you probably already know that there are 4 types of these cells in our eyes - one senses just brightness, the other three sense ROUGHLY red, green and blue wavelengths. Although it's really more complicated. Check this out:

Sensitivity

As you can see, each cell doesn't just respond to a single frequency, but rather to a large range of frequencies, and these ranges overlap A LOT.

In the end, the color that we perceive is determined by the RATIO of the stimulation of all three types of cells. You'll also note that some colors like white or brown aren't even on this chart, because they require more than one frequency of light rays at the same time.

Other animals can have more or less than 3 types of cells, and the colors they perceive will be drastically different from ours. Check out the mantis shrimp which has 12 to 16 types of color receptor cells!!!

Interestingly, there are even some humans with 4 types of cells, although a fully functioning tetrachromacy is very rare.

So back to RGB and CMYK and HSL and whatnotelse. These notations are used because they are convenient ways to describe most colors we humans can perceive. Enough for practical purposes*. But none of them actually cover ALL of the colors that we can perceive. Similarly, I also don't think we've created a device that could create all the possible colors that humans can perceive (but I could be wrong on this one).

And if we wanted to create a mathematical representation of all the colors that a mantis shrimp can see, we'd need 16 components instead of 3 components.

As for treating colors as 3D vectors - uhh, sure? You can do that, mathematically. What that will give you however, I don't know.

*Added: as noted in comments by Edgar Bonnet, there is the CIE 1931 XYZ color space which does cover all possible colors that humans can see.

Vilx-
  • 3,081
  • 4
  • 23
  • 22
  • I think Captain Disillusion has a video about this topic CD / Color. What do you think about it? – Kripke Platek Apr 02 '21 at 10:14
  • @Prithubiswas - I haven't seen that one, but my favorite is from Technology Connections. He also has a few more where he plays around with colors; just browse the channel. – Vilx- Apr 02 '21 at 10:37
  • Re “_none of them actually cover ALL of the colors that we can perceive_”: The CIE XYZ color space does. – Edgar Bonet Apr 02 '21 at 12:27
  • @EdgarBonet: Not quite related to what you were referring to, but it's not clear what it means by "colours that we can perceive" in the more general sense (than what the cones can detect). Look at colour constancy. =) – user21820 Apr 02 '21 at 12:35
  • OK, ok, I admit... I'm not an expert in this field. And kudos about the CIE XYZ - I didn't know that. But, you know, it's obvious that someone should have made that. What I meant is that the most common color spaces we encounter in our every day devices (like RGB, CMYK, HSL, etc) don't cover the full color space visible to most humans. – Vilx- Apr 02 '21 at 12:39
  • Re “_most common color spaces we encounter [...] don't cover the full color space visible to most humans_”: Indeed. I guess that's because those spaces were not designed to represent the colors we can perceive, but the colors we can reproduce with a given technology (RGB for CRTs, CMYK for print). – Edgar Bonet Apr 02 '21 at 14:01
  • Having a large number of colour receptor types does not imply mantis shrimp see a high dimensional color space. In fact, the opposite is likely true: they have many receptor types so as to avoid using a high dimensional color representation.

    "make quick and reliable determinations of color, without the processing delay required for a multidimensional color space" https://www.researchgate.net/publication/259883148_A_Different_Form_of_Color_Vision_in_Mantis_Shrimp

    – Dan Piponi Apr 02 '21 at 15:42
3

It depends on how you use the word "color".

I. You can take three additive primary colors as the basis of a vector space. The combinations of these colors (with positive coefficients) fill out not the entire vector space, but the first quadrant of that space.

But as you move out along any line through the origin, the points all represent the same color, just with different intensities. So if you consider a standardly-imbedded simplex (i.e. the triangle below, with vertices at the standard basis vectors), there is a one-to-one correspondence between colors and points of that simplex.

enter image description here

If you take that simplex and round off the corners, you'll get the "color wheel" that you probably encountered in elementary school.

II. Note that every possible pure frequency of light determines a color, and that you can combine these any way you want. Since there are infinitely many pure frequencies, the possible combinations form an infinite dimensional vector space, which you might want to think of as the space of "colors".

There is a linear map from the infinite dimensional space of colors in sense II to the three-dimensional space of colors in sense I (and from there, by projection along lines through the origin, to the color simplex/wheel), given by mapping a combination of pure frequencies to the way the human eye perceives that combination. Obviously this map cannot be one-to-one, so that for any given color X in sense I there are a vast number of colors in sense II that we perceive as X.

WillO
  • 15,072
  • 2
    Same chromaticity but different luminance doesn't represent "same color, just with different intensities". These are different colors. E.g. orange and brown are different colors, although they differ only in luminance (relative to surround). – Ruslan Apr 01 '21 at 23:09
3

Our perception of colour is reasonably modeled as a 3 dimensional vector with no negative elements. 2*Red is "brighter red", in the limit the Red kills you.

You can actually perceive a limited kind "negative red" using optical illusion tricks; basically, look at a bright red object for a while, then look away at a white object. You'll see an afterimage that is a negative image of the bright red object you saw.

Like all things in physics, the mathematical model has non-universal applicability.

The 3 dimensional colour perception is linked to reality because much of our colour perception comes from 3 different pigments in the eye. These pigments react to light of various frequencies in different amounts, and their differences and intensities are translated (to a first approximation) into that 3 dimensional colour space you are used to.

Light itself is an infinite dimensional vector, where all values are restricted to be positive. Our perception of it, to a first approximation, is a convolution of that infinite dimensional vector space with the pigment frequency response curves.

There are a lot of things that don't exactly match this model. For example, you can take one person and have them mix multiple frequencies to produce a colour that exactly matches a pure frequency, a different person often disagrees with what mixture matches the pure frequency! What more, you can test that this disagreement is "real", in that given two people, one will be able to tell the difference between the mixture and the pure frequency, while the other will not.

This is because there are actually 4 different pigments that are common in the human population; two of them are close mutations of each other. Typically someone has 3 of them, but which of the two variants they have is somewhat random, and (as it lives on the X chromosome) some women have all 4. Those with all four are known as tetrachromats. What's more, almost everyone has this at low light intensities (as our low-light vision is an additional pigment in effect). It is not proven if this results in a different experience of colour vision.

But what you have to do is stop thinking about colours as frequencies as far as human perception is concerned. We rarely see pure frequency light (rainbows and lasers mostly).

PM 2Ring
  • 11,873
Yakk
  • 4,292
2

The way we represent colours is just that: a representation.

When I first worked with Tektronix colour terminals in the late 1970s, we used the HLS system, which was represented as a double cone. The Wikipedia article about HSL/HSV systems shows this model. Similarly, RGB, CMY, HSV and various other systems all use 3 parameters, so they can be represented by a 3D model. The K in CMYK just adds some extra capability; the main reason for having it is that we use so much black by itself.

The reason for using 3 parameters is the fact that our eyes have 3 different colour receptors, the retina's cones, with sensitivities in the red, green and blue wavelength ranges. The peaks of sensitivity are at around 440, 545 and 565 nm. However, the cones have sensitivities over a broad wavelength range and especially the read and green cones have a large overlap.

There is nothing 3-dimensional about the colours themselves. A colour is no more than a mixture of many different wavelengths. The cones in the retina translate those frequencies into different signals for each of the 3 cones. The brain then recombines them into something that we interpret as a certain colour.

In summary, while it is useful to think about colours in a 3D space, there is nothing physical about that, it is just a representation.

hdhondt
  • 10,898
2

I wish to expand on Vilx's answer. First read this post on how we see colour. Next observe that the colour normal humans perceive in a small region depends entirely on the relative intensity of photons that excite those 3 types of retinal cones in the corresponding region on the retina.

So it is more or less correct that colours live in a 3-dimensional space. Moreover, this space is locally quite similar to a vector space, in that the average excitation frequency of cones of each type within a (not too small) region changes roughly linearly with a small change of the incident rate of photons of the same wavelength.

However, as with most things in the natural world, this linear relation will break down for very low or very high photon intensity reaching the eye. After all, when the rate of photons reaching the eye is too low, too much of them get absorbed by the stuff from the cornea to the blood vessels in the retina, so the rate of photons incident on the retina would fluctuate from zero to some low amount, and low signal levels from the retina are actually ignored by the brain (to filter out noise). And when the rate of photons reaching the eye is high, a greater fraction of them will not get absorbed by the cones (because there are only finitely many cones and each has a nonzero latency), so the signal that goes to your brain is not linearly proportional.

With all that said, you should see that it is unclear what it even ought to mean by colours living in a vector space.

user21820
  • 2,880
  • 1
  • 18
  • 26
  • Before you get "fluctuation from zero to some low amount", you'll switch vision to mesopic and then scotopic mode, which will already alter the color space first to a 4-dimensional space, and then reduce it to a 1-dimensional one. – Ruslan Apr 02 '21 at 14:51
  • @Ruslan: Thanks for that additional information! Though it doesn't affect what I said (which is merely about rate of photons incident on the retina). =) – user21820 Apr 02 '21 at 16:51