aldus.nexus

SVD layers

Rebuild an image from its most important layers, one simple stripy pattern at a time.

The numbers

singular values, log
cumulative energy
storage against rank

PCA: the same SVD on a cloud of points

Swap the image for a table: one row per point, one column per dimension. Centre it and run the same SVD. The rows of VT are the principal directions, the ways the cloud stretches most, and σi² says how much of the spread each one carries. Keep the top two and you have the best flat picture of a shape that lives in 3, 5 or 6 dimensions.

arrows: principal axes, 2 standard deviations · plane: PC1 and PC2
dashed: 2 standard deviations
variance explained
principal directionsrows of VT

How it works

An image is a grid of numbers, a matrix A. The singular value decomposition splits it into a sum of layers. Each layer is one column pattern u times one row pattern v, so it can only ever be stripes and plaid. The singular value sigma says how much of the picture that layer carries.

The layers come sorted, biggest first. Keeping the top k gives the closest possible rank k picture (the Eckart-Young theorem), and you only store k columns, k rows and k numbers instead of every pixel.

The geometry view shows the same idea for a 2 by 2 matrix: any matrix is a rotation, a stretch along two axes, then another rotation. A circle always becomes an ellipse, and the stretches are the singular values.

This page computes it by hand with one-sided Jacobi: it keeps rotating pairs of columns until they are all at right angles, in a background worker so the page never freezes.

The PCA section uses the same routine on a cloud of points instead of pixels. Subtract the mean of every column, split the table with the SVD, and the right singular vectors are the principal directions. Projecting onto the top two gives the flat view that keeps the most variance; the bars show the share each direction carries, so a flat disc shows two big bars and a round dust ball shows them all equal.

a photo of a whole nebula is mostly a few dozen plaid patterns added together.

A = U Σ VT = Σi σi ui viTui column pattern, vi row pattern, σ1 ≥ σ2 ≥ ... ≥ 0
energy(k) = (σ1² + ... + σk²) / Σ σi²the share of the picture kept at rank k
Xc = U Σ VT,  λi = σi² / (n - 1)PCA: rows of VT are the principal directions, U Σ the coordinates along them, λi the variance each carries
bytes(k) = k (m + n + 1)per channel, against m n for the raw pixels