The Color Cube

Branko Ćurgus


The Color Cube

In many math classes we work with vectors. I love to use colors to clarify relationship between various mathematical quantities that we encounter. Therefore it is useful to present how colors can be organized using vectors in the unit cube in $\mathbb{R}^3$.


The Following Eighteen Colors Stand Out

It is important to point out that in the red-green-blue coloring scheme, the following eighteen colors stand out. I present them in six steps with three colors in each step.


Transition between Two Colors

Thinking of colors as vectors helps us to understand a transition between two colors.


Converting an Image to Black-and-White,
             Making an Image Darker or Lighter

An application of an orthogonal projection studied in Linear Algebra is converting a color image to a black&white image. To understand this claim, you first need to understand that colors are in fact vectors in $\mathbb{R}^3,$ not all vectors in $\mathbb{R}^3,$ but only vectors confined to the unit cube \[ [0,1]^3 = \left\{ \left[\begin{array}{c} r \\[-4pt] g \\ b \end{array}\right] \, : \, r, g, b \in \mathbb{R} \right\}. \] Here we use so called RGB color model. I like using RGB triplets with entries between $0$ and $1$, including $0$ and $1$.

All shades of gray are obtained by scaling the vector $\left[\begin{array}{c} 1 \\ 1 \\ 1 \end{array}\right]$ with a scalar $\alpha \in [0,1]$. The orthogonal projection onto the vector $\left[\begin{array}{c} 1 \\ 1 \\ 1 \end{array}\right]$ is given by the formula: \[ \left[\begin{array}{c} r \\[-4pt] g \\ b \end{array}\right] \mapsto \frac{1}{3} \left[\begin{array}{c} r+g+b \\[-2pt] r+g+b \\[-1pt] r+g+b \end{array}\right]. \]

In the animation below, the shades of Gray are on the diagonal of the unit cube joining the corners $(0,0,0)$ (Black) and $(1,1,1)$ (White). For the hundred shades of Gray $(a,a,a)$ with $a \in [0,1],$ I present a polygon of all the colors that are projected to that shade of Gray. The shade of Gray can be identified by the dot in the center of the polygon of colors. I present both a three-dimensional picture in the Color Cube and a two-dimensional orthogonal projection onto the plane which is orthogonal to the vector $\left[\begin{array}{c}1 \\ 1 \\ 1 \end{array}\right].$ Hover the cursor over the image for the animation to start.

Here I explore other transformations of colors using Linear Algebra? I took a small image of me, imported the image into Wolfram Mathematica and did three linear algebra operations on the colors in that picture.

The justifications for the definitions in the preceding two items are the pictures below: