HW1 (Due 9/19)
(PCA) Let's try to “compress” an image with PCA. You will need to use Matlab for this problem. Get the mat from here.
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’)”
Now partition the image into \(64\) blocks with size \(64 \times 64\) each. Check out the function mat2cell. It probably helps.
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.
Compute and subtract mean for data.
Obtain forward transform by
Apply SVD directly to data.
Try estimate the covariance matrix and then compute transform using eigen-decomposition on estimated covariance matrix.
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).
|