0% found this document useful (0 votes)
15 views6 pages

DM1580 - LAB 4 Machine Learning Video

The lab focused on using Principal Component Analysis (PCA) to compute eigenfaces for image compression and face reconstruction. A dataset of 13233 face images was reduced to 550 samples, and the reconstruction quality was evaluated using Peak Signal-to-Noise Ratio (PSNR), which indicated that using 50 to 70 eigenfaces provides a good balance between image quality and data efficiency. The results showed that even a small number of eigenfaces captured the main structure of faces effectively.

Uploaded by

Hind Belhouari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

DM1580 - LAB 4 Machine Learning Video

The lab focused on using Principal Component Analysis (PCA) to compute eigenfaces for image compression and face reconstruction. A dataset of 13233 face images was reduced to 550 samples, and the reconstruction quality was evaluated using Peak Signal-to-Noise Ratio (PSNR), which indicated that using 50 to 70 eigenfaces provides a good balance between image quality and data efficiency. The results showed that even a small number of eigenfaces captured the main structure of faces effectively.

Uploaded by

Hind Belhouari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DM1580 - LAB 4

Machine Learning for Video

Group 14
Hind Belhouari
Leon Boman
Roger Vendrell Colet
1. Objective

The objective of this lab was to understand how to compute and use eigenfaces for
image compression and face reconstruction using Principal Component Analysis
(PCA). Specifically, we:

●​ Loaded and prepared a dataset of face images​

●​ Computed the mean face and residual matrix​

●​ Constructed a covariance matrix manually​

●​ Computed eigenfaces (PCA basis functions)​

●​ Projected test images into eigenface space​

●​ Reconstructed test images using a reduced number of eigenfaces​

●​ Measured reconstruction quality using PSNR ​

2. The data
The data we have dealt with consists of a set of images depicting human faces. The
data consists of a total of 13233 samples. The amount of samples has been reduced
to 550 (500 as a training set and 50 as a test set).
The following is an example of the images found in the dataset:
We can see that the faces are centered and aligned. Taking the mean image of all
the faces lets us confirm this, revealing that most images depict a darker pattern on
the eyes and mouth, whereas the forehead and cheeks appear with higher intensity
values:

3. Eigenvector and eigenvalues


Having the faces’ mean image allowed us to compute the residuals of every face
(meaning, the difference between each face and the mean). Then, from the
residuals (I) we could build the covariance matrix (C) using the following formula,

where n is the number of face images. From there, we could compute its
eigenvectors (its main components) and its eigenvalues (which represents the
importance or strength of each component).
The eigenvalue graph shows a rapid decrease in the strength of the eigenvectors of
the covariance matrix. They start to flatten near 0 before the 100th element. This
suggests that taking into account a number of eigenvectors between 0 and 100,
such as 50, is a reasonable choice. Particularly, 50 is 10% of all the available
eigenvectors (which is very valuable reduction from the data compression
perspective), and an amount that still ensures enough expressiveness.

4. Projecting the test set on the obtained basis

Once we have used the training dataset (500 face images) to find the 50 principal
components that better allow to represent the “face signal”, we have used those to
encode previously unseen faces.
This process is particularly interesting from the data compression perspective,
because it allows us to encode every face image with a fixed amount of coefficients
(in our case, the chosen 50). Without the encoding, each image would need 7500
values (100x75 pixels).

5. Reconstruction with K principal components


Once we project every image of the test set onto the 50 principal components
found in the training set, we can represent any previously unseen face image with
only 50 coefficients. To reconstruct the image, we only need to start with the
mean_image vector from the training set and, from there onwards, start adding
each principal component scaled by its coefficient.
This process yields good reconstruction results, as we can see in the following
examples:
Our reconstruction allows for representing the general sense of the face regarding
positioning (eyes, nose, mouth), expression, head direction and brightness of the
skin. However, a lot of detail is still lost, which is what we aim to quantify in the
next section.

6. Peak Signal-to-Noise Ratio (PSNR) in terms of k

To evaluate reconstruction accuracy, we calculated the average PSNR for different


numbers of eigenfaces used k. PSNR measures how close the reconstructed image
is to the original, with higher values indicating better quality.

As shown in the graph, PSNR increases consistently with the number of


eigenfaces. The improvement is rapid for small k values, especially between 1 and
30, where the PSNR rises from around 66.5 dB to 71 dB. This means that even
with a small number of components, the reconstruction already captures the main
structure of the face.

After around k = 50, the curve starts to level off. This means that adding more
eigenfaces doesn't improve the quality much. Between k = 50 and k = 100, the
PSNR only increases slightly ;from about 72 dB to just over 73 dB.

In the end, using about 50 to 70 eigenfaces gives a good balance between quality
and efficiency. The PSNR values stay above 70 dB, which means the reconstructed
faces are very similar to the originals, even when not using all components.

You might also like