SVD layers
Rebuild an image from its most important layers, one simple stripy pattern at a time.
The numbers
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.
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.