Introduction
Oct 10 edit: the third heading has been changed to “Computing E from A”
I want to work an example from Cohen, “Visual Color and Color Mixture” (see the bibliography, and this “books added” post). I am not, however, going to do it exactly the way he did. Nevertheless, I will show you everything he calculated.
Because I want to get everything of his into one post, I will break this into small sections. I expect that my next post will show you what I would have done instead.
All of his matrices can be found on p. 70 of his book.
What we have here is an extremely small example to illustrate “color matching functions” applied to light spectra, resulting in three real numbers which we call R,G,B or X,Y,Z. This is a prelude to using real color matching functions on real spectra. I will refer to the 3 numbers I get during the course of this example as “R,G,B”, in quotes because this is a toy example, and because down the road I’ll be computing “XYZ tristimulus values” in preference to RGB.
The A and E matrices: computing A from E
He has two matrices denoted A and E. They are closely related, and the typing is simpler if I start with the E matrix:
Let me emphasize that the A matrix is primary, and we should have computed the E matrix from it.
Let me answer a question at the outset. What is the point of the A matrix? Applied to a spectrum — careful! it’s actually the transpose A’ that is applied to a spectrum — it generates R,G,B or X,Y,Z values. This will get us from light spectra to colors! And the matrix E contains spectra; more to follow about that, I assure you.
Given E, he would compute the A matrix as
where I will frequently use A’ for the transpose , simply because it is sometimes typographically more convenient — and it is an extremely common notation. But note that I will write
for the inverse transpose. In general, I will use whichever notation is more convenient for any particular expression, and I may even mix them shamelessly.
We get (with 4 places, as he showed it)
Hey what? What did he accomplish with that? First, we may say that he found an A such that both
A’E = I,
and E’A = I,
i.e.
A straightforward way of stating those relationships is: A’ is a left inverse of E; A is a right inverse of E’. We should also observe that by transposing
A’ E = I
we get
E’ A = I,
i.e. the second of those relationships. They are equivalent.
Now, we computed A from E as
,
Please note that the existence of depends on E having more rows than columns, and on E being of full rank. The matrix E is of rank 3, and the 3×3 matrix E’E is invertible. The 7×7 matrix EE’ is not, and can never be (not with E having 3 columns). And, of course, the matrices A and E themselves cannot possibly be invertible, since they are not square.
The A and E matrices: computing E from A
Had we been given the matrix A, we might guess that we could have computed E from A by some similar formula. Let’s try the obvious,
and see what we get. We have
.
That doesn’t look very good — but wait a minute. We have spent a lot of time computing “dispersion matrices”, things of the form E’E — and they are symmetric. That is,
.
So we continue, getting
.
That’s what we were hoping for, that E is computed from A exactly the same way as A was computed from E. Given the matrix A we would compute the matrix E as
.
By the way, we saw, in that process, that
.
This matters later when we define Ma and Me. That latest equation will tell us that Ma and Me are inverses.
The “real” relationship between A and E: dual (reciprocal) bases
All of Cohen’s work in this example treats A and E as matrices. There is another interpretation, a crucial interpretation. I will return to this in another post, but I have to tell you what he “really” did.
We have seen this computation before. Some of you may be sick of it. Well, it isn’t quite what we have seen before.
What we have seen before is a square matrix — specifically a transition matrix defining a basis — and we have wanted to compute the reciprocal basis. I even emphasized that I do not remember the answer, but I remember how to get it. If P is the given transition matrix, and R is the transition matrix for the reciprocal basis, then I want to compute all the dot products of the columns of R with the columns of P, and I want the answers to be an identity matrix. That is, I want an identity matrix to be the matrix product of rows of R’ with columns of P,
R’P = I
so R is the inverse transpose of P:
.
Wait just a minute. For a reciprocal basis, we just wrote
R’P = I.
For A and E, we had
E’A = I.
Guess what? Each column of E is a reciprocal basis vector for the columns of A. What we have are three columns of A, 7-dimensional but spanning a 3-D subspace. And the three columns of E are a reciprocal basis.
For reasons that will be far more obvious later, here is a place where I would choose to call the columns of E a dual basis rather than a reciprocal basis. Computationally — in finite dimensional spaces — there is no difference, but conceptually it will help a lot even there. In fact, I would say that we need to distinquish them conceptually precisely because we can’t tell the difference numerically.
It also turns out that it’s better to think of the columns of E (column vectors) as the original basis, and the rows of A’ (row vectors) as the dual basis. It might be best to think of the pair, columns of E and row of A’, as a set of dual bases, plural. Each row of A’ represents a so-called linear functional, a linear operator mapping a spectrum (a column vector) to a real number (the suffix -al in functional says the output is 1D). If this is new to you, relax. We’ll see it again, with real matrices A and E and real spectra.
I have barely discussed the dual space (that’s where dual vectors live, while reciprocal vectors live in the same space as the original basis) in these posts. We will get to it. If you know about it, good: for color theory, think dual basis rather than reciprocal basis. If you don’t know about the dual space, it’s okay to think reciprocal basis, for a while.
Okay, I’ll tell you that if you’ve ever seen differential forms, you’ve seen dual bases:

I should remark that Cohen never uses either term, reciprocal basis or dual basis. He knows that the relationship between A and E is crucial, he just doesn’t use the mathematical name for the relationship.
Now is a good time to remark, as I have before for other authors, that Cohen was almost certainly breaking new ground. I will not fault him for not saying it “correctly”; he deserves far too much credit for getting the mathematics right in the first place.
So, we still have exactly what we started with, the A and E matrices. In fact, we start with either one of them and get the other.
His dispersion matrices Me and Ma, and their Cholesky (LU) decompositions
I am going to show you the rest of what he did. We will later do almost all of this differently, but I had to know what he was doing. And if you are reading Cohen, then I have to show you a better way to do what he did. He computed (and named) the two intermediate dispersion matrices:
Me = E’E
Ma = A’A
and then he focuses on the inverses and
. Oh, he also knows that Me and Ma are themselves inverses, as I noted earlier when we worked out E in terms of A:
.
(That is, there are only two distinct matrices among these 4 names.)
Anyway, here are Me, and its inverse…
and, for example, Ma…
which is, as it should be, .
Although he did not describe it this way, he next computed two matrices by doing Cholesky decompositions of Ma and Me. I think it is safe to describe the Cholseky decomposition as a special case of the LU decomposition. It is the result of an LU decomposition applied to a positive define symmetric (Hermitian in general) matrix, and the resulting L and U matrices are transposes, so there’s really only one of L and U to be found.
If you are following along with Cohen, let me warn you that I am going to change notation. Why? Because there’s a little magic going on here and a slightly different notation will focus on it. Besides, his notation seems silly. He has A and E, ends up with F1 and F2 — and along the way he uses G and Gbar.
I’ll keep his F1 and F2, since they are among his final results, but I am going to use Ga and Ge for the intermediate G’s. Trust me: you want me to do that.
Let me just do them. For Ma, we get…
What he has found is a lower triangular “square root” of Ma. That is, we have Ga such that
Ga Ga’ = Ma.
(This is his Gbar.)
We do it for Me, too…
As before, we have gotten Ge such that
Ge Ge’ = Me.
Note that I have used Ga and Ge to denote what we took the Cholesky decomposition of: Ga came from A’A, and Ge came from E’E, which is the inverse of A’A.
His orthonormal bases F1 and F2
He then defines
F1 = A Ge
F2 = E Ga.
That is what I want you to see: he uses Ge with A, and Ga with E. This guarantees that F1 and F2 are orthonormal matrices. (See below.) And if I view Ge and Ga as transition matrices, then F1 is apparently a basis for the column space of A, F2 for the column space of E. I have to confess that I don’t really care about F1 and F2 — I can do far better.
But, here are Cohen’s F1 and F2:
Okay, just why did F1 and F2 turn out to be orthonormal? That is, they each satisfy F’ F = I:
Let’s see why. Let’s compute F1′ F1. We have
F1 = A Ge.
Then
F1′ F1 = Ge’ A’A Ge = Ge’ Ma Ge
.
It works out because Ma and Me are inverses, and Ge is used with A to get F1. A similar calculation works for F2.
I want to point out that F1 and F2 are not dual to each other; we have, for example, F1′ F2 != I:
Of course not. Just as an orthonormal basis is its own reciprocal basis, so it “is” its own dual basis, at least in a finite dimensional space. I waffle and use quoted “is”, because the two bases which are dual to each other live in different vector spaces — but if one is orthonormal, the dual has the same numerical components. We will see this explicitly. In this case, it means that F1 “is” its own dual basis, and F2 “is” its own dual basis.
Let me say that again, approximately but simply: F1 is dual to itself, and F2 is dual to itself; they are not dual to each other.
But today we know how to get such bases without the Cholesky decomposition. We also know that we can use the same orthonormal basis for both of those spaces.
I will do that in the next post.
Using the A matrix: applied to the columns of E
I ask again, what is the point of the A matrix? Applied to a spectrum — careful! it’s actually the transpose A’ that is applied to a spectrum — it generates “R,G,B” values. Of course, this A matrix is a toy, but better to start with 3×7 than 3×81 or even larger. We’ll get there.
There are two interesting possible spectra to which we might apply A’, even from a toy matrix A. The obvious possibility, to me at least, it to apply A’ to E. (That is, we are applying A to 3 spectra at once.) Now, we already know the answer, because E was chosen as the dual basis. That is, we have already seen that
A’E = I.
That is, if we let the columns of E be E1, E2, E3, then we have
A’ E1 = (1,0,0)
A’ E2 = (0,1,0)
A’ E3 = (0,0,1).
In words, E1 is a spectrum which leads pure red; E2 generates pure green; and E3 generates pure blue. More precisely, E1 (etc.) is a spectrum which generates our chosen red. I’ll make more sense of that when we have real A matrices. (Oh, yes, there are more than one.)
Using the A matrix: applied to an equal energy (constant) spectrum
The second possibility is an equal energy spectrum:
Let’s not worry too much about that negative value; what it means is that we cannot actually match the equal energy spectrum (with whatever our toy “R,G,B” light sources are); instead, we have to add red light to the equal energy spectrum, and match that resulting mixture.
Perhaps now is a good time to say that the key point here is that we get 3 values; our perception of color vision is specified by 3 numbers. In practice, “CIE tristimulus values X,Y,Z” will be our objective.
The projection matrix R
There is one final crucial question. A’ maps from 7D to 3D. It is of full rank 3, so it has a nullspace of dimension 4. (If you need, now would be a good time time to look at fundamental subspaces.)
There are a whole lot of spectra out there whose R,G,B values are {0,0,0}. More importantly, any given spectrum can be split into two vectors, one in the nullspace of A’ and the other in the preimage of its range (i.e. in the range of A).
How would we find that decomposition?
Any direct sum decomposition has projection operators associated with it, so let’s find the projection operator onto the preimage of the range.
Malinowski did that. I did it differently. Cohen does it the same way Malinowski did, but it looks more compact because he defines both E and A. Cohen writes
R = E A’.
If we use
to expand Cohen’s equation, we get
.
We have also seen that this is the “hat matrix”, which projects an observation onto the subspace spanned by the least-squares fit. That is, we have
,
and
,
so
and if we define the hat matrix H by
,
we have
yhat = H y.
The key is that H is to X as R is to A.
Just for completeness, I compute R as Cohen did:
Since we know that projection operators are idempotent, we can check that . (It is.)
The projection of the columns of E
Having gotten the projection operator R, let’s use it. First, apply it to E, the dual basis to the rows of A’.
I hope it is not a surprise that we just got E back: the projection of E is E.
But what does that mean? No part of any column of E is in the nullspace of A’.
The projection of the equal energy spectrum
Recall the equal energy spectrum:
I will denote the projection as f, for fundamental.
Well, that has a nontrivial component in the nullspace, call it n. (We know that, as soon as we see f != ee.) We have
ee = f + n,
where n is simply the difference, n = ee – f, namely
Direct computation confirms that n is in the nullspace of A’:
Hang on just one second. What would you call a color whose “R,G,B” values were all zero?
I would call it black.
Because n itself, however, is a nontrivial spectrum — in the sense that there’s light there at each of those 7 frequencies! — let us refer to that spectrum as metameric black. (Two different spectra are said to be metamers or metameric if they appear to be the same color under the same illumination.)
It’s black to our eyes. (Although I could guess that if it were sufficiently intense, we might find ourselves with sore eyes from the radiation that is hitting them.)
I would emphasize that n depends more on A’, in a sense, than on the original equal energy signal ee. Of course, it came from ee and its fundamental, but once I have this n, I could add it to any other spectrum (of length 7!) without affecting the observed color of that spectrum. (In fact, it will depend on the illumination, too, but I’ll show you that. For now, pretend the illuminant is equal energy, too.)
The point is that in the real world, with real spectra — from pine needles or from some Munsell color chip or anything — every “metameric black” we compute could be added to any other spectrum we have, without affecting the color we perceive.
This, if northing else, reminds us that color is our perception of a light spectrum. And there are physical spectra in the visble region that appear black to us.
We can confirm that the fundamental f has precisely the same “R,G,B” values as the equal energy signal, by computing A’ f
Recall, or recompute A’ ee
The same. We have indeed split ee into two parts
ee = f + n,
one of which (n) contributes nothing to the final R,G,B values, the other of which (f) contributes everything. This is why f is called the fundamental.
And, our observation that the columns of E are projected onto themselves says that the columns of E are also fundamental spectra.
And they are a basis, so every fundamental — everything we see — could be written as a linear combination of the columns of E. They’re not an orthonormal basis, so we would have to use the dual basis to compute coefficients of the linear combinations. Well, that’s exactly what we accomplish by applying A’ (the dual basis) to the fundamental.
Those 3 numbers (A’f = A’ ee) we get describe the fundamental f in terms of the basis vectors E1, E2, E3:
f = R E1 + G E2 + B E3.
They are simply the components of f wrt the basis E1, E2, E3.
They are not, however, the coefficients of the original signal ee. That lies not entirely in the space spanned by E — that’s what the metameric black n is, the part of the original signal that is not in the space spanned by E.
(They also are not necessarily the RGB values we would use in RGB color space. After all, the components of f could be any real numbers, while RGB color space has restricted values, whether 0 to 1, 0 to 100, or 0 to 255. Don’t worry, we’ll get there.)
Summary
Cohen has a matrix A of “color matching functions”; it has 3 columns and lots more rows.
We construct a dual basis E via
.
Since “dual basis” is a dual relationship, we could have — and did! — compute A from a given E:
We construct two dispersion matrices
Me = E’E,
Ma = A’A,
and we saw that they were inverses.
We did Cholesky decompositions (LU decompositions of positive definite symmetric matrices) of Ma and Me, getting
Ga Ga’ = Ma,
Ge Ge’ = Me.
Then we used Ge and Ga to construct two orthonormal bases F1 and F2
F1 = A Ge,
F2 = E Ga.
Finally, Cohen computed the projection operator R onto the non-nullspace part of the domain of A’ (the preimage of the range of A’, equivalently the image of A).
Most importantly, at the end, we saw that an equal-energy (constant) spectrum could be split into two parts (f and n), one of which (f) contained all the “R,G,B” nformation, the other of which (n) was metameric black, invisible.
Next, I will show what I would do differently.
December 18, 2009 at 12:31 pm
Hiya!. Thanks for the blog. I’ve been digging around looking some info up for shool, but i think i’m getting lost!. Google lead me here – good for you i guess! Keep up the good work. I will be coming back in a couple of days to see if there is any more info.
December 19, 2009 at 9:40 am
Hi Amber,
You’re welcome. I try to put out a new post every weekend — usually Sunday, but sometimes Monday evening.
Feel free to ask questions about what’s on the blog. (But I can’t promise to answer questions about _other_ material.)