Run the SVD compression code in Matlab (or any other language). A) Estimate for which value of q the energy norm' retained in the
Run the SVD compression code in Matlab (or any other language). A) Estimate for which value of q the energy norm' retained in the compressed image is 99% of the original 2-norm? B) Compute the resulting compression ratio? % SVD compression code for color images clear all; close all; q=200; gray value 901 X0=imread('C:\Users\brio\Desktop\Math 322\Lecture Notes\ Linear Algebra\glassware.jpg'); figure (1) imshow (X0) title ('Original image') X=double (X0)/255; [m, n,p] = size (X); X = reshape (X,m, p*n); [V,S,U] svd (X', 0); % sigma-diag (S); q=max(find (sigma>mu* sigma (1))); %could be used to find q for given threshhold a=diag (S) '/S (1, 1) * 100; a=[100-a (2:length (a) -1), 100]; figure (2) plot (a (1: q), 'ro') title('Scaled singular values') k = 1:q; X = U(:,k) *S (k, k) *V (:, k) '; X = reshape (X, m, n,p); color images figure (3) imshow (X, []); comment out for gray, use only for title (['Compressed image with q = , num2str(q)])
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started