HW1 (Due 9/19)

  1. (PCA) Let's try to “compress” an image with PCA. You will need to use Matlab for this problem. Get the mat from here.

    1. Let's make sure we are in the same pace. Load it into matlab using “load('lena512.mat’)”. You can show it with “imagesc(lena512)”. If the color doesn't look right, try “colormap('gray’)”

    2. Now partition the image into \(64\) blocks with size \(64 \times 64\) each. Check out the function mat2cell. It probably helps.

    3. Rearrange the blocks into a data matrix, with each row is a data point (\(64 \times 64=4096\) components) and a total of \(64\) data points. Your data matrix should have a size of \(64\) by \(4096\) if you follow what we explained in the slides.

    4. Compute and subtract mean for data.

    5. Obtain forward transform by

      1. Apply SVD directly to data.

      2. Try estimate the covariance matrix and then compute transform using eigen-decomposition on estimated covariance matrix.

    6. Keep only the first 10 principle components for both approaches and reconstruct the image.

Please hands in the code and show me the reconstructed image. You may also try to keep first 20, and 50 principle components and see how things change. You may try to use different block size (say \(32 \times 32\) or \(16 \times 16\) also).