Starting from:

$25

AMATH301-Homework 9 Solved

AMATH 301

Homework #9

1.    Read the image arnold01.jpg into Matlab and convert it to a grayscale image with double precision numbers by using the following commands.

A = imread(‘arnold01.jpg’);

A = double(rgb2gray(A)); Plot the image using the commands:

imagesc(A) colormap gray

(a)    Perform a singular value decomposition on the matrix A that was generated by the image arnold01.jpg. Create a 10×1 column vector that contains the ten largest singular values of A. Store this vector in A1.dat. The cumulative energy in the first r modes is the sum of the first r (i.e. r largest) singular values divided by the sum of all of the singular values. Calculate the cumulative energy in the first 10 modes and save it in A2.dat.

(b)    Find the smallest value of r such that the cumulative energy in the first r modes is greater than 0.5. Save the value of r in A3.dat. Approximate the matrix A by using the first r modes (i.e. the first r columns of U, the first r singular values, and the first r rows of V T, where U and V come from the SVD). Subtract this approximation from the original matrix A and then calculate the size of the error by using the norm command (use the default matrix norm and NOT the infinity norm). Save the error in A4.dat. Plot the approximation using imagesc and compare with the original image.

(c)     Now find the smallest value of r such that the cumulative energy in the first r modes is greater than 0.9. Save the value of r in A5.dat. Just like in part (b), approximate the matrix A by using the first r modes, calculate the error, and save the error in A6.dat. Plot the approximation using imagesc and compare with the original image.

Things to think about: What were the values of r that you found in parts (b) and (c)? How much less information needs to be stored if you just keep the truncated versions of U, Σ, and V ? How good do the approximations look? How much cumulative energy do you think is needed for a “good” approximation?

2.    Use the load command to load the data in NoisyImage.mat. Two matrices should appear in your workspace. The matrix A is the true version of some image and the matrix A_noise is a noisy version of the same image. Plot both images using the imshow command and compare them. The goal of this problem is to denoise the noisy image.

(a)    Calculate the error between the matrix A and the matrix A_noise by subtracting and taking the norm. Save the error in A7.dat. Perform a singular value decomposition on the matrix A_noise. Save the largest singular value in A8.dat.

(b)    Calculate the cumulative energy in the first 2 modes and save it in A9.dat. Then approximate the matrix A_noise by using the first 2 modes. Calculate the error between the matrix A which represents the true image and this approximation. Save the error in A10.dat. Plot this approximation and compare to both the true image and the noisy image.

Things to think about: Look at all of the singular values of A_noise (or at least the first 20). Do a singular value decomposion on A and look at the singular values.

How do they compare? Does this explain why using the first 2 modes of A_noise was so effective? Do you think the denoising process would be more difficult on a different image?

More products