lab6343

pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

325

Subject

Mathematics

Date

Feb 20, 2024

Type

pdf

Pages

6

Uploaded by LieutenantMetalPartridge38

Report
MAT 343 Lab 5 - Abhikya Reddy Ananth A=imread( 'gauss.jpg' ); %reading the image B=double(A(:,:,1)); %convert to double precision B=B/255; %scale the values of B [U S V] = svd(B); %compute the SVD decomposition of B Problem 1 Compute the dimensions of U, S and V %finding dimensions disp( "U=" ) U= size(U) %displays size of U ans = 1×2 393 393 disp( "S=" ) S= size(S) %displays size of S ans = 1×2 393 613 disp( "V=" ) V= size(V) %displays size of V ans = 1×2 613 613 Problem 2 Compute the best rank-1 approximation and store it in rank1 k = 1; % defining ran to 1 rank1 = U(:,1:k)*S(1:k, 1:k)*V(:,1:k)'; %this is to find rank 1 for B sing U, S, V Visualize rank1 by performing steps 3 -6 C = zeros(size(A)); % visualizing rank C(:,:,1) = rank1; C(:,:,2) = rank1; C(:,:,3) = rank1; C = max(0,min(1,C)); image(C), axis image %helps to view the image 1
Problem 3 Create and view a rank-10 approximation to the original picture k=10; %defining rank to 10 rank1 = U(:,1:k)*S(1:k, 1:k)*V(:,1:k)'; C = zeros(size(A)); % visualizing rank C(:,:,1) = rank1; C(:,:,2) = rank1; C(:,:,3) = rank1; C = max(0,min(1,C)); image(C), axis image %helps to view the image 2
Problem 4 Experiment with different ranks until you found one that gives, in your opinion, an acceptable approximation. for k=[20 30 40] %repeating with ranks 20, 30, 40 rank1 = U(:,1:k)*S(1:k, 1:k)*V(:,1:k)'; C = zeros(size(A)); % visualizing rank C(:,:,1) = rank1; C(:,:,2) = rank1; C(:,:,3) = rank1; C = max(0,min(1,C)); figure(k); image(C), axis image %helps to view the image end 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
4
%In my opinion rank-40 gives an aceptable range Problem 5 What rank-r approximation exactly reproduces the original picture? Explain, Answer: It would be rank of B , which is 255, The image is made up of different levels of grey on a 255 bit scale Problem 6 (i) How much data is needed to represent a rank-k approximation? Explain. Answer: After experimenting in problem 4. I found out that rank-40 gives an appropriate approximation therefore k is 40 this data can be evaluated by using the formula k+(k*m)+(k*n) where m is 613 and n is 393 . The result of the formula is 40280. Therefore we can say the data needed to represent rank-40 approximation is 40280. (ii) Find the compression rate for the value of the rank you determined in problem 4. Explain. Answer: Compression rate = (data of rank-40 approximation)/(data used for the original image) 40280 / ( 613*393) = 0.16720006309 Thus after calculation we find that rank-40 has a compression rate of 0.16720006309 ( 16.72%) What does the compression rate represent? Explain. 5
Answer:The compression rate represents ratio of the amount of data used in rank-approximation to the amount of data used in the original image. Problem 7 Find the smallest value of k such that the rank-k approximation uses the same or more amount of data as the original picture. Explain how you obtained the answer. Answer: In order to find the smallest value of k , we can set the compression rate to 1 , or 100% and solve for k with the formula k = (m*n)/(2*(m+n)) k = ( 613*393)/(2*(613+393)) = 240909/2012 = 119.736083499 Thus, the smallest value of k would be 119.736083499. 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help