LINEAR-ALGEBRA Β· Interactive Practice | Unit 30 Β· Video 3

P = Wc: The Matrix Equation Behind Image Compression

IKey Formulas

Formula Name Description
P=WcP = Wc Change of basis Signal PP as combination of basis columns of WW with coefficients cc
c=Wβˆ’1Pc = W^{-1} P Inverse transform Recover coefficients from the signal
WTW=Iβ‡’Wβˆ’1=WTW^T W = I \Rightarrow W^{-1} = W^T Orthonormal property Inverse is just the transpose β€” blazing fast
w^i=wi/βˆ₯wiβˆ₯\hat{w}_i = w_i / \lVert w_i \rVert Normalization Turns an orthogonal basis into an orthonormal one

IIVisualization 1 β€” Coordinates Depend on the Basis

The same coefficients cc build a different vector P=WcP = Wc once the basis WW changes.

IIIVisualization 2 β€” Sparsity Beats Pixels

Keep only the largest few coefficients in each basis, reconstruct, and compare the error.

Standard (pixel) basis

Haar wavelet basis

πŸ’‘ Packing a signal's energy into a few large coefficients β€” sparsification β€” is exactly what JPEG and JPEG 2000 exploit to compress images.

IVVisualization 3 β€” Orthogonal, but Not Yet Orthonormal

Distinct Haar columns dot to zero β€” yet a column dotted with itself is its squared length, not 11.

πŸ’‘ Dividing each column by its length normalizes WW into an orthonormal matrix, where Wβˆ’1=WTW^{-1} = W^{T}.

VQuiz Questions

Question 1

Let W=(111βˆ’1)W = \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} and c=(32)c = \begin{pmatrix} 3 \\ 2 \end{pmatrix}.

Using P=WcP = Wc, what is PP?

βœ… Correct! P=3w1+2w2=(5,1)P = 3w_1 + 2w_2 = (5, 1).

❌ Not quite. Remember: WcWc is the linear combination c1w1+c2w2c_1 w_1 + c_2 w_2 where wiw_i are the columns of WW.

Show solution

Solution:

Compute WcWc column by column: P=c1w1+c2w2=3(11)+2(1βˆ’1)=(3+23βˆ’2)=(51).P = c_1 w_1 + c_2 w_2 = 3 \begin{pmatrix} 1 \\ 1 \end{pmatrix} + 2 \begin{pmatrix} 1 \\ -1 \end{pmatrix} = \begin{pmatrix} 3+2 \\ 3-2 \end{pmatrix} = \begin{pmatrix} 5 \\ 1 \end{pmatrix}.

Question 2

A matrix WW has columns that are mutually orthogonal, but each column has length 2\sqrt{2} (not 1).

Is it true that Wβˆ’1=WTW^{-1} = W^T?

βœ… Correct! Orthogonal is not enough β€” you also need unit length (orthonormal). Here WTW=2IW^T W = 2I, so Wβˆ’1=12WTW^{-1} = \tfrac{1}{2} W^T.

❌ Not quite. Orthogonality gives WTWW^T W diagonal, but only orthonormal columns (unit length) make it the identity.

Show solution

Solution:

Orthogonal columns alone are not enough. If column ii has length 2\sqrt{2}, then wiβ‹…wi=2w_i \cdot w_i = 2, so WTW=2I(notΒ theΒ identity).W^T W = 2 I \quad \text{(not the identity).}

This gives Wβˆ’1=12WTW^{-1} = \tfrac{1}{2} W^T, not WTW^T itself. You need columns of unit length β€” i.e., orthonormal β€” for Wβˆ’1=WTW^{-1} = W^T. Normalize each column by dividing by its length.

Question 3

Two competing strategies, both keep only 10% of the data:

  • Strategy A: keep 10% of the raw pixel values (standard basis), set the rest to 0.
  • Strategy B: keep the 10% largest wavelet coefficients, set the rest to 0, then reconstruct.

Why does Strategy B produce a far better image than Strategy A?

βœ… Correct! Sparsification is the key β€” wavelets pack the signal's energy into a few coefficients.

❌ Not quite. Re-read the answer about energy concentration.

Show solution

Solution:

This is the sparsification criterion. A good basis WW should express the signal PP as WcWc where most entries of cc are tiny and only a few are large. Then we keep the big ones and discard the rest β€” losing almost nothing.

  • In the standard basis, every coefficient is a pixel. Discarding 90% of pixels literally creates holes in the image.
  • In the wavelet basis, a few coefficients capture the smooth structure; the small ones encode noise-level details. Throwing them away barely changes the reconstruction.

This is the core idea behind JPEG (DCT) and JPEG 2000 (wavelets).

Question 4

For a megapixel image, WW is roughly 106Γ—10610^6 \times 10^6. Computing Wβˆ’1W^{-1} from scratch takes about n3β‰ˆ1018n^3 \approx 10^{18} operations β€” infeasible.

Which property of WW rescues us by making c=Wβˆ’1Pc = W^{-1} P as cheap as one matrix-vector multiplication?

βœ… Correct! Orthonormality turns the inverse into a transpose β€” and a transpose is essentially free.

❌ Not quite. Think about which property makes WTW=IW^T W = I, so that Wβˆ’1=WTW^{-1} = W^T.

Show solution

Solution:

When WW is orthonormal, WTW=IW^T W = I, so Wβˆ’1=WTW^{-1} = W^T. Transposing a matrix is essentially free β€” you just reinterpret the indices. So c=Wβˆ’1Pc = W^{-1} P becomes c=WTPc = W^T P, a single matrix-vector multiplication.

This is exactly why the FFT, DCT, and wavelet transforms all use orthonormal bases: speed.

(Note: WW being diagonal would also be fast, but then it wouldn't mix coordinates at all β€” useless for compression. Square and integer-valued don't help with inversion cost.)

Solved: 0 / 4