0% found this document useful (0 votes)
6 views8 pages

SVD and PCA in Image Reconstruction

The report discusses a programming assignment involving image reconstruction using Singular Value Decomposition (SVD) and Principal Component Analysis (PCA). It details the methodology for reconstructing grayscale images with varying singular values and the impact of Gaussian noise on image quality, as well as the reconstruction of face images using PCA. Observations indicate that retaining more singular values or principal components enhances image quality, but with diminishing returns, and noise primarily affects higher singular values.

Uploaded by

Raghav Borikar
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)
6 views8 pages

SVD and PCA in Image Reconstruction

The report discusses a programming assignment involving image reconstruction using Singular Value Decomposition (SVD) and Principal Component Analysis (PCA). It details the methodology for reconstructing grayscale images with varying singular values and the impact of Gaussian noise on image quality, as well as the reconstruction of face images using PCA. Observations indicate that retaining more singular values or principal components enhances image quality, but with diminishing returns, and noise primarily affects higher singular values.

Uploaded by

Raghav Borikar
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

DSL 502 – BASIC MATHEMATICS FOR DSAI

PROGRAMMING ASSIGNMENT – REPORT

Q1.) Take any Gray Level image and perform the following tasks using Singular Value
Decomposition (SVD):
(a) Reconstruct the image by retaining different numbers of singular values (eigenvalues).
Illustrate and discuss how the quality of the image changes as the number of singular values
retained increases or decreases. (10 points)
(b) Add Gaussian noise to the original image and reconstruct it using SVD.
Compare the noisy reconstruction with the original (non-noisy) reconstruction, and explain
the effect of noise on the quality of the reconstruction. (10 points)

Objectives

1. Reconstruct a grayscale image using various numbers of singular values.


2. Evaluate how image quality changes with an increasing number of retained singular
values.
3. Add Gaussian noise to the original image and observe how noise affects
reconstruction quality.
Methodology

Step 1: Loading and Preparing the Image


1. A grayscale image was selected and loaded into the analysis environment.
2. The image was converted into a 2D numpy array for processing.

Step 2: Singular Value Decomposition (SVD)


Using SVD, we decomposed the image matrix A into three matrices:
A=UΣVT
where:
• U and V are orthogonal matrices.
• Σ is a diagonal matrix containing singular values in descending order.

Step 3: Image Reconstruction with Varying Numbers of Singular Values


1. We reconstructed the image by varying the number of singular values retained (from 1
up to the total number of singular values).
2. For each reconstruction, only the top k singular values were kept in Σ, where k is the
number of components used.
3. The images were regenerated using the truncated matrices U, Σk, and V for each k.

Step 4: Adding Gaussian Noise


1. Gaussian noise was added to the original image to observe the effect of noise on the
reconstruction quality.
2. The noisy image was then reconstructed using the same SVD-based approach, with
various numbers of singular values retained.
Observations and Results

Part (a): Effect of Singular Values on Image Quality


The image was reconstructed with varying numbers of singular values (1,2,5,10, 20, 50 and so
on), and the quality was assessed at each stage. The following observations were made:
1. Low Singular Values (1 to 5):
o With a very small number of singular values, the image was blurred and lacked
detail.
o Not even the most basic structure was retained, and fine details were lost.
2. Intermediate Singular Values (10 to 50):
o As more singular values were retained, the image quality improved significantly.
o Key details of the image, such as outlines and textures, became more visible.
3. High Singular Values (100 and above):
o With a high number of singular values, the reconstructed image began
resembling the original image.
o The quality improvement between retaining 200 and 500 singular values was
less dramatic, indicating diminishing returns as we approach the total number
of singular values.
4. Full Set of Singular Values:
o When all singular values were retained, the reconstructed image was identical
to the original image, as expected.

Summary of Part (a)


The quality of the reconstructed image improved as the number of retained singular values
increased, but the improvement was not linear. Most of the essential information was
captured by the top 100 to 200 singular values, and retaining additional values only slightly
enhanced the quality.
Part (b): Effect of Noise on Reconstruction Quality
1. Reconstruction from Noisy Image with Low Singular Values:
o When retaining only a few singular values, the noisy reconstruction was similar
to the clean reconstruction.
o Gaussian noise mainly affected the finer details, which were not captured with a
low number of singular values.
2. Reconstruction from Noisy Image with High Singular Values:
o As more singular values were retained, noise became more apparent in the
reconstructed image.
o Noise was particularly noticeable in the background and areas with uniform
texture, where high-frequency details were more sensitive to noise.
3. Comparison with Non-Noisy Reconstruction:
o The noisy reconstruction showed artifacts and grainy textures at higher
numbers of singular values.
o The noise had less impact on lower singular values, which represent the general
structure rather than fine details.

Summary of Part (b)


The reconstruction of the noisy image demonstrates that noise primarily affects the higher
singular values, which correspond to fine details. By retaining fewer singular values, we can
somewhat reduce the impact of noise on the image, although at the cost of losing image detail.
Conclusion

1. Singular Values and Image Quality: Retaining a higher number of singular values
results in higher-quality reconstructions. However, diminishing returns occur after a
certain point, where additional singular values do not significantly improve image
quality.
2. Noise and Reconstruction: Noise in the image primarily affects the higher singular
values, meaning that the overall structure of the image can be preserved by discarding
some of the noisier components. This trade-off can be useful when reconstructing
images in noisy environments.
Q2.) Use PCA (KL Transform) to obtain the reduced dimension representation of the face
image [Link] Illustrate the reconstructed
image using different Principal Components. For example, reconstruct the face images using
the 5th to 10th Principal Components. Write your observations. (10 points)

Objective

The goal of this project is to explore Principal Component Analysis (PCA) on face images and
examine the impact of the number of retained Principal Components (PCs) on image
reconstruction quality. Here, I detail the image reconstruction results for
(1) a single image,
(2) multiple images of the same person, and
(3) images of different individuals.
The effects of retaining different numbers of PCs are analyzed for image quality and data
compression.

Methodology for Each Scenario

Single Image Reconstruction:


o A single grayscale face image is used to train PCA.
o The PCA model is trained on the 180×200 image, treating each row as a sample.
o Reconstructed images are generated by retaining PCs from the list [1, 2, 5, 10,
25, 50, 100, 180].
Multiple Images of the Same Person:
o A set of 20 images of the same individual is used to train PCA with a maximum
of 20 PCs possible.
o Each image is reshaped and flattened into a vector, forming a data matrix of
dimensions 20×36000.
o Reconstructed images are generated by retaining PCs from [1, 2, ..., 20].

Images of Different Individuals:


o A set of 10 grayscale images of 10 different individuals is used to train PCA with
a maximum of 10 PCs.
o The PCA model is applied to reconstruct each individual's image, using PCs from
[1, 2, ..., 10], resulting in 100 reconstructed images.

Analysis and Visualization:


• For each scenario, the reconstruction quality is visualized, and images are compared
qualitatively to assess how well the reconstructed images resemble the originals as
the number of retained PCs increases.
• Additional analysis includes plotting the explained variance of each PC and cumulative
variance to understand the contribution of each PC toward the image data.

Observations and Results

1. Single Image Reconstruction:


o Reconstruction Quality: With only a few PCs (1, 2, 5), the images are highly blurred
and lose detailed facial features. With 10-25 PCs, basic facial structures emerge,
but finer details remain absent. As more PCs (50, 100) are added, the image
quality improves, and the original structure is more closely approximated.
o Explained Variance: The variance captured by each PC diminishes gradually after
the initial components, indicating that the majority of facial information is
encoded in the first 50 PCs.

2. Multiple Images of the Same Person:


o Reconstruction Quality: As the images correspond to the same person, hence
overall variance is quite low. Due to this, even with less Principal Components,
we are able to get moderately well reconstructed images.
o Variance Distribution: The first few PCs explain most of the variance, but with
increased PCs, finer, person-specific details are retained, essential for a more
accurate reconstruction.
3. Images of Different Individuals:
o Reconstruction Quality: At 1-3 PCs, only general shapes are visible without any
clear individual features. With 4-6 PCs, distinguishing features unique to each
person’s face (such as the shape of the nose and eyes) start appearing. At 7-8
PCs, images gain fine details with most of the details getting captured, in fact
PCs 9 & 10 are not much needed.
o Variance Distribution: PCs are distributed across individual variations, capturing
prominent facial structures early on. However, due to individual differences,
some more PCs are required for identifying distinct features across different
faces.

Common questions

Powered by AI

In PCA-based reconstruction of face images, the quality improves as more Principal Components (PCs) are retained. With only a few PCs, images are highly blurred with missing details . Retaining 10-25 PCs helps capture basic facial structures, but finer details are lacking. Using 50-100 PCs significantly enhances image quality, closely approximating the original structure. For multiple images of the same person, fewer PCs are needed for moderate reconstruction due to low variance in differing details. However, for different individuals, at least 7-8 PCs are needed to capture distinguishing features and minimize the need for PCs 9 and 10 .

Gaussian noise primarily affects higher singular values, which correspond to fine image details. When few singular values are retained, the noisy reconstruction is similar to the clean reconstruction as the noise mainly impacts finer details not captured with low singular values. As more singular values are retained, noise becomes more apparent, causing artifacts and grainy textures, particularly in uniform areas. This indicates that while retaining fewer singular values can reduce noise impact, it sacrifices detailed reconstruction .

To balance noise reduction with detail retention in SVD-based image reconstruction, a selective retention of singular values is necessary. Retaining only the singular values that capture essential image structure while discarding those representing fine details can reduce noise's impact. Experimenting with the highest singular values (determined by testing with clean and noisy versions) and selecting a cut-off point based on visual quality assessments can enhance reconstruction quality. Additionally, applying thresholding techniques to distinguish between noise-influenced and genuine image details in high singular values can improve outcomes .

Retaining a low number of singular values results in similar reconstructions for both noisy and non-noisy images because noise predominantly affects higher singular values that capture finer details . As more singular values are retained, noise becomes more apparent in the reconstructed image, particularly in backgrounds and uniform textures. This is because higher singular values, which contain noise, contribute more significantly, leading to increased artifacts and graininess compared to non-noisy reconstruction. This highlights the trade-off between capturing fine details and minimizing noise impact .

In PCA, images of different individuals impact the distribution and requirement of Principal Components (PCs) significantly. The primary PCs capture prominent and common facial structures, but capturing unique features across different individuals requires more PCs. The diversity in individual features disperses across PCs such that while few PCs provide general structural information, more components are needed to adequately capture distinguishing facial characteristics. As a result, retaining a higher number of PCs ensures accurate reconstruction by accounting for individual variance .

The quality of an image reconstructed using SVD improves as the number of retained singular values increases. Retaining a very small number of singular values (1-5) leads to a severely blurred image with almost no recognizable details. Increasing the number of retained values (10-50) significantly improves image quality by enhancing key details like outlines and textures. When a high number of singular values (100 and above) are retained, the reconstructed image closely resembles the original image. However, beyond a certain point (around 200 singular values), the improvement becomes less noticeable, indicating diminishing returns .

Noise predominantly affects high-frequency details in images reconstructed using SVD. High singular values correspond to these fine details and are more susceptible to noise. In areas with uniform textures where high-frequency details exist, noise becomes more visible when a larger number of singular values are retained. Conversely, low-frequency details or general structures, represented by lower singular values, are less influenced by noise. Thus, reducing higher singular values can minimize noise impact but will also lead to a loss of detail .

PCA effectively manages variance among multiple images of the same individual by focusing most of the variance in the first few Principal Components (PCs). This allows for moderate quality reconstructions even with fewer PCs due to low overall variance. As more PCs are added, finer, person-specific details are captured, resulting in a more accurate reconstruction. This demonstrates PCA's capacity for efficient compression and reconstruction without a significant loss of detail for similar images .

The explained variance in PCA indicates the proportion of total data variance captured by each Principal Component (PC). Initially, a few PCs account for most of the variance, highlighting their importance in capturing essential image features. Observing the cumulative variance helps determine the number of PCs needed for effective reconstruction. If a substantial percentage of variance (e.g., 90-95%) is captured by a relatively low number of PCs, it indicates that rebuilding the image with these PCs would maintain high quality while achieving efficient data compression .

In singular value-based image reconstruction, significant quality improvements are seen with an increase in retained singular values up to a point. Most of the essential image information is captured by the top 100 to 200 singular values. Beyond this, additional singular values provide only slight enhancements to the image quality, indicating diminishing returns. Thus, while it is beneficial to retain many singular values for better quality, retaining values beyond a certain point does not yield significant improvements .

You might also like