Question
Answered step-by-step

Working to complete parameters for rank approximations in MATLAB.

I would like to know how to generate ranks, root mean square errors between matrices, the value of k, compression ratio and display an image and compute (RMSE) from original image to approximations. CR=2,10,25, and 75.


below is the code I've managed to generate and have had no success in completing an image.


Problem 1
Use the svd() function in MATLAB to compute , the rank-1 approximation of . Clearly state what is, rounded to 4 decimal places. Also, compute the root-mean square error (RMSE) between and .
Solution:
%code
A = [1 2 2; 3 4 5; 6 7 8]
B = double(A);
B = B/225;
[U,S,V] = svd(B)
checkBUSV = U*S*V.'
[QB, RB] = qr(B)
checkBQBRB = QB*RB
Usize = size(U);
Ssize = size(S);
Vsize = size(V);
rankA = rref(A)
rankA1 = B(:,1)
A = max(0,min(1,A))
n = max(size(A))
RMSEAA1 = sqrt(1/n*sum(A-rankA1).^2)


Problem 2
Use the svd() function in MATLAB to compute , the rank-2 approximation of . Clearly state what is, rounded to 4 decimal places. Also, compute the root-mean square error (RMSE) between and . Which approximation is better, or ? Explain.
Solution:
%code
C = zeros(size(A))


rankA2 = B(:,2)
RMSEAA2 = sqrt(1/n*sum(A-rankA2).^2)
Explain: 


Problem 3
For the matrix , the singular value decomposition is where . Use MATLAB to compute the dot product .  
Also, use MATLAB to compute the cross product and dot product . Clearly state the values for each of these computations. Do these values make sense? Explain.
Solution:
%code
u1 = U(:,1);
u2 = U(:,2);
u3 = U(:,3);
d1 = dot(u1,u2)
c = (cross(u1,u2))
d2 = dot(c,u3)
Explain:


Problem 4
Using the matrix , determine whether or not the columns of span . Explain your approach.
Solution:
%code
temp = rref(U)
[L, U] = lu(U);
Explain: %There are 3 pivots in the temp row reduction of U, which means the row rank is 3. The theorem informs that the row rank = the column rank of a matrix, It is also known that the coloumn rank of A is 3. Therfore there must be 3 linearly independent columns of U that span R.


Problem 5
Use the MATLAB imshow() function to load and display the image stored in the image.mat file, available in the Project Two Supported Materials area in Brightspace. For the loaded image, derive the value of that will result in a compression ratio of . For this value of , construct the rank-k approximation of the image. 
Solution:
%code
k1 = rankA1(1,:)
k2 = rankA2(2,:)
rankA3 = B(:,3)
RMSEAA3 = sqrt(1/n*sum(A-rankA3).^2)
k3 = rankA3(3,:)
CR = S./k1(A+rankA1+1)


figure;
imshow(A)
title('My Image Title KG')


Explain:
Problem 6
Display the image and compute the root mean square error (RMSE) between the approximation and the original image. Make sure to include a copy of the approximate image in your report.
Solution:
%code
image(C), axis image


Problem 7
Repeat Problems 5 and 6 for , , and . Explain what trends you observe in the image approximation as increases and provide your recommendation for the best based on your observations. Make sure to include a copy of the approximate images in your report.
Solution:
%code


Explain:

Answer & Explanation
Verified Solved by verified expert
Rated Helpful

a molestie consequat, ultrices ac magna. Fusce dui lectus, congue v


usce dui lectus, congue vel laoreet ac, dictum

rem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultri

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer
Step-by-step explanation

usce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui

Student reviews
50% (6 ratings)

"Thank you for the clarification to help support the problems introduced. I'm still not able to import, load, and read the image.mat file. Any resources or suggestions would be greatly appreciated. =)"