Image Compression
Images as Matrices: Low-Rank Approximation, Storage Cost and Reconstruction Error
An image is a matrix
A grayscale image with m rows and n columns of pixels is a real m×n matrix A, each entry holding one intensity. Stored naively it costs mn numbers. The compression question is whether a matrix that came from a photograph, a scan or a satellite image has structure that a smaller collection of numbers can capture.
It usually does. Real images are full of repeated and smoothly varying structure: a clear sky, a wall, a gradient of shading. Repeated and smoothly varying structure can make the rows and columns lie approximately in low-dimensional subspaces. Near-proportional rows or columns are the special case of approximate rank one.
The singular value decomposition and its truncation
Every real m×n matrix factors as
with orthonormal ui∈Rm, orthonormal vi∈Rn, and r the rank. Each term σiuiviT is a separable rank-one image: every row is a scaled copy of one fixed row profile, and every column is a scaled copy of one fixed column profile. The sum layers them in order of decreasing weight.
Keeping the first k terms gives the truncated SVD, or rank-k approximation:
The Eckart–Young theorem says this is the best possible choice: among all matrices of rank at most k, Ak minimises ∥A−B∥F, and it minimises the spectral norm of the error as well. No cleverer rank-k approximation exists.
What a rank-k image actually costs to store
Storing Ak does not mean storing the mn entries of the reconstructed image. It means storing the ingredients: k left singular vectors of length m, k right singular vectors of length n, and k singular values. Throughout this concept we use that convention:
The compression ratio compares this with the original cost:
Worked example. Take a 512×512 image and keep k=40. The original holds 512×512=262144 numbers. The rank-40 representation holds
Two habits are worth forming here. Compute m+n+1 once and reuse it. And keep the ratio and percentage straight: the fraction of original size is the reciprocal of the compression ratio, 1/ratio; as a percentage, it is 100/ratio%. Thus, a ratio of 6.39 corresponds to about 100/6.39=15.6% retained, not 6.39%.
Break-even: when low rank stops saving anything
Storage grows linearly in k, so the method saves space only while
For a square N×N image the bound is roughly N/2. Past that rank you are storing more numbers than the picture contained to begin with.
This matters in practice because it converts “how many components do I need?” into a hard feasibility test: if an image needs a rank near or above the break-even value to look acceptable, low-rank approximation is the wrong tool for it.
Measuring the error
Because the singular vectors are orthonormal, the squared Frobenius norm splits cleanly across the components:
Two different quantities are built from these sums, and confusing them is the most common error in this topic.
- The fraction of energy retained is ∑i≤kσi2/∑iσi2.
- The relative Frobenius error is ∥A−Ak∥F/∥A∥F=∑i>kσi2/∑iσi2.
These are not complements of one another. If the discarded energy fraction is d, the relative Frobenius error is d. Retaining 99% of the energy leaves d=0.01 and a relative error of 0.01=10%, not 1%. The factor between the discarded fraction and the relative error is 1/d, so it depends on the discarded fraction.
Everything depends on how fast the singular values decay
Whether low-rank compression works at all is decided by the shape of the sequence σ1,σ2,…. Rapid decay, geometric, say, means a handful of terms carry nearly all the energy and a very small k suffices.
Slow decay, a power law like σi∝i−1/2, means energy is spread thinly over hundreds of components, and the rank required for a decent reconstruction can exceed the break-even bound entirely.
Irregular fine texture and uncorrelated sensor noise often spread energy across many singular components; structured textures can still be low rank.
Two practical notes. First, the error above is measured in the Frobenius norm, which weights every pixel equally; the human visual system does not, so the Frobenius-optimal approximation is not necessarily the most convincing one to look at.
Second, the SVD is a global factorisation of the whole image. Many practical codecs, such as baseline JPEG, apply a discrete cosine transform to blocks, while others use different structures, including wavelet transforms.
Those codec-specific transforms are outside this low-rank SVD concept. General least-squares theory and face-recognition applications belong to their own siblings; here the object of study is the low-rank approximation of the image matrix and its cost.
A grayscale photograph is stored as a 256×384 matrix. It is compressed by keeping the rank-30 truncated SVD, storing 30 left singular vectors, 30 right singular vectors and 30 singular values.
How many real numbers does the compressed representation store?
Give your answer in real numbers.
An image block has exactly five nonzero singular values:
Let A2 be the best rank-2 approximation to this block. Calculate the relative Frobenius error ∥A−A2∥F/∥A∥F, to three decimal places.
Give your answer as a number.