Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was given this code function svd-figure(filename) % % svd-figure(filename) % % read in an image and spit out svd approximations more off; A =

I was given this code

function svd-figure(filename)

%

% svd-figure(filename)

%

% read in an image and spit out svd approximations

more off;

A = imread(filename);

A = double(A);

m = size(A,1);

n = size(A,2);

h = size(A,3);

for i=1:h

ranks(i) = rank(A(:,:,i));

end

rmax=min(ranks);

for i=1:h

[U(i).data,S(i).data,V(i).data] = svd(A(:,:,i));

end

indices = [1:5];

%indices = [1:10, 20:10:rmax];

for r=indices

fprintf(1,'r = %d ',r);

for i=1:h

Amod(:,:,i)=U(i).data(:,1:r)*S(i).data(1:r,1:r)*V(i).data(:,1:r)';

Adiff(:,:,i) = U(i).data(:,r)*S(i).data(r,r)*V(i).data(:,r)';

end

Amod = uint8(Amod);

Adiff = uint8(Adiff);

rstring = sprintf('%d.jpg',r);

imwrite(Amod, rstring,'jpg');

end

more on;

and use it to import a photo, with Matlabs imread command. Use the SVD to create 8:1, 4:1, and 2:1 compressed versions of the photo. Note that this compression refers to the total memory required to store the approximation. Please report how many singular values were required for each of the compression ratios.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What are the HR forecasting techniques?

Answered: 1 week ago

Question

=+management system of the MNE?

Answered: 1 week ago