Rebuild it, one layer at a time
On the left, the picture as the computer sees it: a grid of numbers. On the right, the same picture rebuilt from only the first k layers. Drag the slider and watch it sharpen. Each layer costs one column of numbers, one row and one weight, so a few layers take far fewer numbers than the whole grid.
Start at k = 1 and slide right. Tap the button the moment you recognise who it is.
"Save image" makes a picture card on this device. Nothing is uploaded.
What one layer looks like
Every layer is the simplest possible picture: one column of numbers (the teal and amber strip down the left) times one row of numbers (the strip along the top). So every row of a layer is the same pattern, just brighter or dimmer. One such pattern can't draw a face. Add them up, biggest first, and it appears. These are the first eight of the greyscale version.
Layer 1
Layer 1 is a blurry average of the whole picture. Each later layer is a correction: it adds light in some places and takes it away in others. The weight in front of each layer, its σ, says how big that correction is. They always come out sorted, biggest first, and every layer is to the others: none repeats what another already said.
Why a few layers carry most of a face
This chart is the importance of each layer: its singular value σ, relative to the first. The scale is logarithmic: each gridline is ten times smaller than the one above. A face falls off a cliff. A few big layers, then a long tail of tiny ones you can drop without noticing. Random noise is different: after its first layer, which is just its average grey, every layer matters about as much as the next. There's no shortcut, so noise can't be compressed.
The same number of layers on random noise. It never "appears": it just gets slowly less wrong. Pick in the hero to try it at full size.
A matrix is a move
So far a matrix has been a picture. It is also an instruction: a way to move every point of a flat plane. A 2×2 matrix sends the arrow along the bottom edge (teal) to its first column, and the arrow up the side (amber) to its second. Everything else, your picture included, comes along for the ride. Drag the arrow tips, drag the numbers sideways, or type them.
What it does to area
Every move is rotate, stretch, rotate
Here is the surprising part. Whatever numbers you put in, the move can be done in three simple steps: turn the picture, stretch it along the two straight axes, turn it again. That's the SVD of this little matrix. The circle shows it best: every matrix turns a circle into an ellipse, and the stretches are the ellipse's two half-widths, the .
In symbols, M = UΣVT: VT is the first turn, Σ the stretch, U the second turn. For a photo it's the same idea with hundreds of dimensions instead of two. If the matrix flips the picture, the flip is shown here as a negative stretch, to keep both turns as pure turns.
Where this is used
The SVD is one of the workhorses of data science. Wherever data sits in a table, the first few layers often carry the signal and the rest carry noise. Some honest examples, and one common myth.
Principal component analysis (PCA)
Put a dataset in a table, one row per person and one column per measurement, and subtract each column's average. The SVD of that table gives its : the directions where the data varies most, ranked. It's how researchers squeeze 20,000 gene readings or 100 survey answers into a 2D map you can actually look at.
Jolliffe and Cadima (2016), Phil. Trans. R. Soc. A.
Eigenfaces
This page splits one picture into layers. Eigenfaces did it across many: stack hundreds of face photos as rows of a table and the SVD finds the shared "face ingredients". Sirovich and Kirby showed in 1987 that a few dozen of them describe a face well; Turk and Pentland used them for recognition in 1991. Today's face recognition doesn't work this way: it uses deep neural networks. Eigenfaces is the classic stepping stone.
Sirovich and Kirby (1987), JOSA A; Turk and Pentland (1991), J. Cognitive Neuroscience.
The Netflix Prize
In 2006 Netflix offered $1 million to anyone who could beat its film recommender by 10%. Picture a table of users and films with each star rating filled in. The big idea that spread through the contest: explain that table with a few hidden layers, like "how much of a thriller is it" and "how much does this person like thrillers". Strictly, it's an SVD-like factorisation, because most of the table is empty and a true SVD needs every cell. A team won in 2009 by blending hundreds of models. Netflix said it put the two strongest early models, a factorisation and another method, into production, but not the full winning blend.
Koren, Bell and Volinsky (2009), IEEE Computer; Funk (2006), "Try this at home"; Netflix (2012), tech blog.
Removing noise
If the signal lives in a few big layers and noise is spread evenly across all of them (the flat amber line above), then throwing away the small layers throws away mostly noise. Gavish and Donoho worked out exactly where to cut: for an n×n table with noise of known size σ, keep the singular values above (4/√3)·√n·σ and drop the rest. Used in sensors, medical imaging and data cleaning. For everyday photos, dedicated denoisers do better.
Gavish and Donoho (2014), IEEE Trans. Information Theory.
"This is how JPEG works"
It isn't. JPEG cuts a photo into 8×8 blocks and uses the . That uses the same fixed set of wave patterns for every photo, so the patterns never need to be stored. The SVD finds the best patterns for your photo, but then you must store them: that's the k×(m+n+1) on the meter above, and it's why the SVD loses at compression.
Wallace (1992), "The JPEG still picture compression standard".
Why the first k layers are the best k
The Eckart–Young theorem (1936) says that no picture of k is closer to the original than the first k SVD layers, measured by the sum of squared pixel errors. So the slider above isn't just one way to compress: by that measure it's the best way with k layers.
Eckart and Young (1936), Psychometrika.
How it works
A photo is a matrix
A greyscale photo is a grid of brightness numbers, one per , from 0 (black) to 1 (white). That grid is a , with m rows and n columns. A colour photo is three of them, one each for red, green and blue. This page shrinks your photo so its long side is 256 pixels, then works on each colour separately (or on one grey matrix, with "Grey").
Any matrix splits into layers
The singular value decomposition says that any matrix A, of any shape, can be written as
U and V are : their columns are at right angles to each other and have length 1, so they only turn things, never stretch them. All the stretching is in Σ, a diagonal list of σ1 ≥ σ2 ≥ … ≥ 0. Multiply it out and the same thing reads as a sum of layers:
Each uiviT is a column times a row: a . The number of layers, r, is the of the matrix. For a photo it's almost always the length of the shorter side: 205 for the paintings here.
Counting the numbers
The full image stores m×n numbers. Keeping k layers stores k columns of m numbers, k rows of n numbers and k weights: k×(m+n+1). For a 256×205 picture, 10 layers is 4,620 numbers instead of 52,480, under 9%. Keep every layer and you store more than the image itself, which is one reason nobody compresses photos this way (see the JPEG card).
Energy
Square every pixel value and add them up: that's the image's . Because the layers are orthogonal, it splits exactly: layer i holds σi2 of it. So "energy kept" on the meter is σ12 + … + σk2 divided by the total. The part left over is exactly the squared error of the rebuilt picture. Energy is not the same as "looks right": layer 1 alone usually holds most of the energy (about 80% for the Vermeer), because it carries the overall brightness, yet it looks like a smudge. Your eyes care about edges, which live in the small layers.
How the page computes it
The decomposition runs in a background thread (a Web Worker) so the page never freezes. It uses the classic Golub–Kahan–Reinsch algorithm, ported from JAMA, a public-domain maths library from NIST. It takes a fraction of a second on a laptop and a second or two on a phone, for four matrices: red, green, blue and grey. After that, moving the slider only adds or removes layers from a running total, so it stays smooth. Your photo, its numbers and the layers stay in this tab's memory and vanish when you close it.