How many simple pieces does a picture need? Watch a photo rebuilt from 1, 2, 4, 8, 16 and 32 of them.
A photo from a few pieces
A picture is a matrix: keep only its largest singular pieces.
A 128 × 128 picture made of numbers, one for each pixel: 16 384 of them.
Describe this picture
A greyscale picture made in code: a sky that fades from top to bottom, a bright disc, a diagonal edge, and grainy textured ground below it. It is shown rebuilt from , 2, 4, 8, 16 and 32 pieces, 1.5 s each, with written in its corner. At it is a soft plaid, horizontal bands times vertical bands: every row is a multiple of one row. Each step adds edges, then the disc’s outline, then the grain. Beside it (below it on a phone), a bar chart of the picture’s first 64 singular values on a log scale, largest first, with the kept bars lit. Readouts give , the numbers stored, , against the picture’s own 16 384, and the share of the energy kept. One control after the clip: a slider for from 1 to 128.
A picture is a matrix
A greyscale picture is a table of brightness values, one per pixel, so it is a matrix. The picture at the top is : 16 384 numbers. By The singular value decomposition, it is a sum of rank-one pieces,
with the singular values in decreasing order. Each piece is a column times a row. Every row of it is a multiple of the same row , and every column a multiple of the same column . As a picture, one piece is a plaid: horizontal bands times vertical bands. That is why the first frame of the clip looks like a plaid, not blurred in the usual way.
Watch out
A low-rank picture is not a low-resolution picture, and it does not keep the brightest pixels. It keeps every pixel, built from a few whole patterns. The first pieces carry the broad shapes, and the later ones add finer and finer detail.
Keep the largest pieces
Keep only the first pieces:
Here the subscript counts the pieces kept: is not the power , and not a column of . The matrix has rank . And no matrix of rank is closer to . This is the Eckart–Young theorem. The error is exactly what was dropped, measured two ways:
- the largest stretch of the error is the first singular value left out, ;
- the sum of the squared entries of the error is the sum of the squares left out,
The share of the total kept is . In the bar chart of the picture, a few tall bars carry most of it.
A small example
Here is a matrix whose pieces have whole-number singular values:
with , , and , , . Both sets are orthonormal. Check one pair: .
Three tiles
N = 27 u_1 v_{1}ᵀ + 18 u_2 v_{2}ᵀ + 9 u_3 v_{3}ᵀ, one piece at a time.
N_1 = 27 u_1 v_{1}ᵀ: every row is a multiple of (2, 2, 1). The error has size 20.12, and 64.3 % of the energy is kept.
Describe this picture
Two grids of cells side by side, each cell shaded by its number. On the left, rebuilt in three stages: the first piece alone, , whose rows are all multiples of ; then plus ; then plus , which gives exactly. Each cell changes to its new number as a piece is added. On the right, the error , what is still missing, shrinks stage by stage to all zeros. Readouts give the number of pieces and the size of the error: 20.12, then 9, then 0. There is no control.
One piece. : every row is a multiple of . The squared entries of add up to , and keeps of that. Its error has largest stretch 18 and Frobenius size .
Two pieces. keeps , and its error is the last piece alone:
with Frobenius size 9.
Counting the numbers
A piece of an matrix needs numbers: the column, the row and the scale. So needs , against for the whole matrix.
- The picture: numbers against 16 384. It saves space only while ; at it stores 16 448, more than the picture.
- A picture has 262 144 numbers. Rank 20 needs , which is 7.8 % of them.
So low rank pays when a few pieces carry most of the picture, as they do for smooth scenes, and not for pure noise.
Limits of low rank
Real image formats do not use the SVD. A JPEG file uses the cosine transform of The discrete cosine transform, a fixed basis that needs no pieces to be stored and costs far less to compute. Low rank is a model: it works when the data really are made of a few patterns, as a ratings table or a set of similar signals often are.
In signal processing · separable filters
An image filter whose kernel is a column times a row is called separable, in Image filtering in the signal processing course. The Sobel kernel is , a rank-one matrix. So it can be run as a column pass and a row pass, products per pixel instead of 9.
Worked example
1. The pieces of . Singular values 27, 18 and 9, with the vectors above.
2. Best rank one. keeps 64.3 % of the squared size; its error is 18 in largest stretch and 20.12 in Frobenius size, which is 0.598 of the whole, .
3. Best rank two. keeps 92.9 %; its error is , 9 in both measures, 0.267 of the whole.
4. Storage. Rank 20 of a picture stores 20 500 numbers, 7.8 %; break-even is near .
Try these before you read the answers.
- What is the rank of a column times a row, ? 1.
- A picture whose rows are all equal: how many singular values are not zero? One.
- The largest-stretch error of the best rank-two approximation of ? .
Where you’ll meet this
Denoising. Measurements of a few true patterns plus noise give a matrix with a few large singular values and many small ones. Keeping the large pieces and dropping the rest removes much of the noise.
Recommendations. A table of ratings, people by items, is close to low rank: tastes come in a few kinds. The best low-rank fit fills in the missing ratings.
Fast filters. A two-dimensional Gaussian blur kernel aligned with the image’s axes is a column times a row, so blurring costs two short passes, not one long one. A Gaussian stretched along a slant is not rank one.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Pieces | each piece: every row a multiple of one row | |
| Best rank | no rank- matrix is closer | |
| Largest-stretch error | the first value dropped | |
| Frobenius error | everything dropped | |
| Share kept | ||
| Storage | against | pays only for small |