Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Image can be found on google lena.bmp Problem 2. (40 points) In this problem, we will see how a change of basis helps in image

Image can be found on google lena.bmp

image text in transcribed

image text in transcribed

Problem 2. (40 points) In this problem, we will see how a change of basis helps in image com- pression. From CCLE, download the bitmap mage Lena.bmp. On MATLAB, use the cornmand SAdouble ('Lena.bmp'), This reads the bitmap image and stores the color scale of each pizel in a matrix. Notice that the variable A is now a 512 512 matrix. Each value of the matrix corresponds to the colorscale of the pixel in the image. To recover the image from the matrix, use the command >>imshow (uint8 (A)); This should output the following image: So now, we can forget about the image and work with the matrix. Note that we need 512 512 = 262144 real values to represent this image. We will now try to reduce the number of real values needed to represent this image, albeit at the cost of the clarity of the image. At this point, we introduce something called the singular-value decomposition (SVD). Any matrix A can be decomposed as A -USVT, where the rows of U form an orthonormal basis for the rows of A and the columns of VT form an orthonormal basis for the columns of A. In effect, we are representing the matrix A in a different orthonormal basis. Note that this is analagous to DTFS there we represent a signal (or a vector) in a different orthonormal basis. To understand SVD further, you can check out any intermediate linear algebra course online. For this homework, this is all you need to know: SVD is essentially representing a matrix using a different orthonormal basis The information about the bases are contained in matrices U and V and the representation of A in these bases is given by the matrix S, which is a diagonal matrix (this matrix has non-zero values only in its diagonal entries, it is zero everywhere else). The diagonal entries of S are called the "singular values" of A The tasks: (a). (30 points) On MATLAB, use the command >> [U, S, V] =svd (A) to get the singular value decomposition of the image matrix. Extract the diagonal entries of S and store it in an array singvals. The array singvals now contains the singular val- ues in decreasing order. Now, from the array singvals, extract the indices of those singulair values which are at least 0.01 of the largest singular value. You can use the MATLAB command >>indices find (singvals >-0.01*max(singvals)) Now construct new matrices U.red, Sred, V.red as follows: U.red is a matrix which contains only the columns of U corresponding to the indices obtained above. For erample, if indices-[1, 4, 5], then U.red is a matrix with only 3 columns, where the first column of U.red is the first column of U, the second column of U.red is the fourth column of U, and the third column of U_red is the fifth column of U. . S.red is a diagonal matrix corresponding to the indices obtained above. For example, if indices [1, 4, 5], then S.red is a 3 x 3 matrix with the 3 diagonal entries as the first, fourth and fifth diagonal entries of S. . V.red is a matrix which contains only the columns of V coTresponding to the indices obtained above. This is similar to constructing U.red from U. Now construct an approximation of A using matrices U.red, S.red, V.red as follows: >>A.redUred * S.red V.red; Use imshow () to display the image corresponding to Ared. Attach the MATLAB script you wrote above with our submission, and also the image you obtained with A red (b). (10 points) Question: We saw earlier that we need 262144 real values to represent A. Simi- larly, we need 262144 real values to represent A.red as well. Instead, note that U.red, S.red, V.red contain all the information needed to construct Ared. How many real values do we need to store U.red, S.red, V_red? How much better is this compared to storing A? Problem 2. (40 points) In this problem, we will see how a change of basis helps in image com- pression. From CCLE, download the bitmap mage Lena.bmp. On MATLAB, use the cornmand SAdouble ('Lena.bmp'), This reads the bitmap image and stores the color scale of each pizel in a matrix. Notice that the variable A is now a 512 512 matrix. Each value of the matrix corresponds to the colorscale of the pixel in the image. To recover the image from the matrix, use the command >>imshow (uint8 (A)); This should output the following image: So now, we can forget about the image and work with the matrix. Note that we need 512 512 = 262144 real values to represent this image. We will now try to reduce the number of real values needed to represent this image, albeit at the cost of the clarity of the image. At this point, we introduce something called the singular-value decomposition (SVD). Any matrix A can be decomposed as A -USVT, where the rows of U form an orthonormal basis for the rows of A and the columns of VT form an orthonormal basis for the columns of A. In effect, we are representing the matrix A in a different orthonormal basis. Note that this is analagous to DTFS there we represent a signal (or a vector) in a different orthonormal basis. To understand SVD further, you can check out any intermediate linear algebra course online. For this homework, this is all you need to know: SVD is essentially representing a matrix using a different orthonormal basis The information about the bases are contained in matrices U and V and the representation of A in these bases is given by the matrix S, which is a diagonal matrix (this matrix has non-zero values only in its diagonal entries, it is zero everywhere else). The diagonal entries of S are called the "singular values" of A The tasks: (a). (30 points) On MATLAB, use the command >> [U, S, V] =svd (A) to get the singular value decomposition of the image matrix. Extract the diagonal entries of S and store it in an array singvals. The array singvals now contains the singular val- ues in decreasing order. Now, from the array singvals, extract the indices of those singulair values which are at least 0.01 of the largest singular value. You can use the MATLAB command >>indices find (singvals >-0.01*max(singvals)) Now construct new matrices U.red, Sred, V.red as follows: U.red is a matrix which contains only the columns of U corresponding to the indices obtained above. For erample, if indices-[1, 4, 5], then U.red is a matrix with only 3 columns, where the first column of U.red is the first column of U, the second column of U.red is the fourth column of U, and the third column of U_red is the fifth column of U. . S.red is a diagonal matrix corresponding to the indices obtained above. For example, if indices [1, 4, 5], then S.red is a 3 x 3 matrix with the 3 diagonal entries as the first, fourth and fifth diagonal entries of S. . V.red is a matrix which contains only the columns of V coTresponding to the indices obtained above. This is similar to constructing U.red from U. Now construct an approximation of A using matrices U.red, S.red, V.red as follows: >>A.redUred * S.red V.red; Use imshow () to display the image corresponding to Ared. Attach the MATLAB script you wrote above with our submission, and also the image you obtained with A red (b). (10 points) Question: We saw earlier that we need 262144 real values to represent A. Simi- larly, we need 262144 real values to represent A.red as well. Instead, note that U.red, S.red, V.red contain all the information needed to construct Ared. How many real values do we need to store U.red, S.red, V_red? How much better is this compared to storing A

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions