Question: 1 . 1 Load and prepare the data set [ 1 0 pts ] . There are a total of 1 2 8 8 images

1.1 Load and prepare the data set [10 pts].
There are a total of 1288 images in this data set and each image is a 5037 matrix.
Images are typically converted to a single vector of pixel values and are stacked as
columns of the matrix. Therefore, this image data set can be stored as a 18501288
matrix, where the 1850 is due to 5037. The dataset images.mat is available on
Canvas. Load this file to your Matlab workspace:
>> B = l o a d ( images . mat ). image data ;
and make sure the matrix B is 18501288.
The original images are in color; we will convert it to grayscale for convenience. This
scales the matrix such that all elements are in [0,1]. You can do this using the
mat2gray() function in Matlab as:
3
>> B = mat2gray ( B ) ;
Now you should have the matrix ready for further analysis.
Deliverables 1.1.
Plot the first 10 images of the data set to confirm it matches Figure 1.
To plot images, you must (1) reshape each column of B into a 5037 matrix us-
ing the reshape() function: >> firstimage = reshape(B(:,1),[37,50]),(2)
then, use imshow() function to plot each image using the reshaped column: >>
imshow(firstimage),(3) to plot an array of images as in Figure 1, use the subplot()
function in Matlab.
1.2 Compute and plot the eigenvalues [15 pts].
We will first compute symmetric matrix from the data set; for this compute A = BB,
which should be a 18501850 square matrix. Then, use the eig() function in Matlab
to compute both eigenvalues and eigenvectors.
Deliverables 1.2.
The eig() function will produce 1850 eigenvalues, but you would see that
18501288=562 eigenvalues are nearly zero. These 562 eigenvalues and
the corresponding eigenvectors are due to numerical error and should be re-
moved. Try the index slicing in MATLAB to truncate the arrays of eigenvalues
and eigenvectors that you obtain from eig().
Plot the remaining 1288 eigenvalues on a log-log plot in decreasing order of mag-
nitude (that is, your plot should show a curve that is decreasing in magnitude
from left to right).
Explain what the large and small eigenvalues mean.
Caution: Matlab computes eigenvalues and eigenvectors in reverse order. That is, the
first column of U corresponds to the smallest eigenvalue (which is the first diagonal
element at (1,1) in D) and so on. Therefore, you must reverse this order before
plotting. Check out flip() in Matlab.
4
1.3 Plot the eigenvectors [10 pts].
Deliverables 1.3.
From the eigen decomposition you did in the previous part, plot the first 10
eigenvectors corresponding to the 10 largest eigenvalues. Plot as images. Briefly
explain what you observe from the plots.
Plot the last 10 eigenvectors corresponding to the smallest 10 eigenvalues. Plot
as images. Explain the difference with the plot in the previous step
I really need help on 1.3. I cannot seem to get the 2 additional plots. Please help me find the code using MATLAB. Thank you
1 . 1 Load and prepare the data set [ 1 0 pts ] .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!