

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


principal component analysis (PCA), which in turn uses Singular Value Decomposition (SVD). The general idea is that our image is stored as a matrix, where each element of the matrix represents a pixel. We can store information about this whole matrix, or we can compute the SVD, and store information about P , S and QT^. If we consider only the information in P and Q corresponding to the rst few diagonal entries of S, then we've greatly reduced the storage size. As you'll see in this project, the rst few terms in the SVD corresponding to the large eigenvalues contain most of the information contained in the image, while the latter terms contain very little information.
The idea is that if B is an n × n matrix containing our image, we compute the SVD: B = P SQT^ which we can write as
B = P SQT^ = (p 1 , p 2 ,... , pn)
s 11 0 · · · 0 0 s 22
0 · · · 0 snn
q 1 T q 2 T .. . qnT
= p 1 s 11 qT 1 + p 2 s 22 q 2 T + · · · + pnsnnqnT
where pi are the columns of P , qi are the columns of Q and sii are the diagonals of S (the singular values). Recall that in SVD, the sii are arranged in order according to size. So s 11 ≥ s 22 ≥ · · · ≥ snn and the terms pisiiqiT with i small will contribute more to the sum that the latter terms. This means one can consider only a few of these terms, and still recover information about the image.
One problem, is that if the full SVD is kept, then we've gone from n^2 elements of B to 2 n^2 + n elements in the SVD (n^2 from P , n^2 from Q and n from S), but, if only a few terms in the SVD sum are kept, then we've greatly reduced the amount of stored information. For example, if only p 1 s 11 q 1 T is kept then this is just 2 n + 1 elements. If we have a 1000 × 1000 image (only 1 megapixel) then we've got from 1 , 000 , 000 elements to only 2001 , reducing the image size by nearly 500 times!
The goal in your assigment is to apply this procedure to an image of your face, analyze the error in the image keeping only a certain number of terms in the SVD, and approximate the storage savings in using the SVD. You should turn in your code (should be a single .m le), a typed document that answers each of the questions asked as part of the assigned problem, and the one single page that contains the 6 images requested (clearly they will not be 600 × 600 ).
(a) Reads you JPEG image (and converts to grayscale, if necessary). (b) Compute the full SVD of your image matrix (the B matrix in the example) and returns the elements as P, S and Q where B = P SQT^. Note: Here we use S instead of Σ simply so we don't have to type Sigma into Matlab.
(c) Insert code which computes the reduced SVD using only the rst k terms. (d) Insert code which computes the error in using the reduced SVD versus the full SVD. This formula is in the notes, and relates the sum of the singular values.