Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Summer 2022 Math 3607: Project 3

2022

Instructions

• You are not allowed to use MATLAB commands and functions other than the ones discussed in lectures, accompanying live scripts, textbooks, and homework/practice problem solutions.

• You may be requested to explain your code to me, in which case a proper and satisfactory explanation must be provided to receive any credits on relevant parts.

• You are allowed to collaborate in a group of up to three students. In such a case, submit a single file to Gradescope. The uploader must select all group members at the time of upload. If the uploader does not select the group members, they will not receive credit.

• If any code is found to be plagiarized from the internet, you will receive a zero on the entire project and will be reported to the COAM.

• Do not carry out computations using Symbolic Math  Toolbox.  Any work done using sym, syms, vpa, and such will receive NO credit.

• Notation. Problems marked with r are to be done by hand; those marked with  are to be solved using a computer.

• Answers to analytical questions (ones marked with r ) without supporting work or justifi- cation will not receive any credit.


1    Polynomial Evaluation of Matrices                                [25 points]

Let ppzq c1 ` c2 z ` ¨ ¨ ¨ ` cnzn ´1 . The value of p for a square matrix input is defined as ppXq “ c1I ` c2X ` ¨ ¨ ¨ ` cnXn´1 .

(a) r Show that if X = Rk ˆk  has an EVD, then ppXq can be found using only evaluations of p at the eigenvalues and two matrix multiplications.

(b) Complete the following program which, given coefficients c “ pc1 , c2 , . . . , cnqT , evaluates the corresponding polynomial at x, which can be a number, a vector, or a square matrix. If x is a scalar or a vector, use Horners method1; if x is a square matrix, use the result from the previous part.

function  y  =  mypolyval (c ,  x)

%MYPOLYVAL  evaluates  a  polynomial  at  points    x    given  its  coeffs .

%  Input :

%       c       coefficient  vector   (c_1 ,  c_2 ,   . . . ,  c_n)^T

%      x      points  of  evaluation

%                -  if  x  is  a  scalar  or  a  vector ,  use  Horners  method

%                -  if  x  is  a  square  matrix ,  use  the  result  from   (a)

%                -  otherwise ,  produce  an  error  message .

(c) Test your code by comparing against MATLAB’s built-in functions. Use polyval for cases where x is a scalar or a vector and polyvalm for cases where x is a square matrix.  Recall that MATLAB uses a different convention in arranging polynomial coefficients, so you need to use flip accordingly.


2     Embedding Watermark inside Image                       [25 points]

Let A and W be m-by-n matrices representing two grayscale images of the same pixel dimensions as shown below. The image W is embedded inside the image A using an SVD-based scheme described below. 

 

Figure 1: Two original images. The image represented by A on the left and the image represented by W on the right.

Let A “ UΣVT  be an SVD of A.  For some small scaling factor α ą 0, construct a new matrix Σ ` αW and consider its SVD

Σ ` αW “ UwΣwVw(T) .                                                          (1)

Note that both Σ and Σw  are diagonal matrices and, for a suitably chosen α , Σ « Σw . Thus, Aw obtained by

Aw  “ UΣwVT                                                                                         (2)

is approximately equal to A and so represents an image which looks nearly identical to that of A, while containing information about the image W as well.

Your mission, should you choose to accept it, is to establish an algorithm to retrieve (an approxi- mation of) W embedded in Aw  given Uw , Vw , Σ , and α .

Begin by loading the data with

>>  load  watermark    %  download  and  save  watermark .mat’  first

This loads Aw, Uw, Vw, S, and alpha, which correspond to Aw , Uw , Vw , Σ , and α as described

above, respectively.  Note that Aw is a matrix of double-precision floating point numbers whose elements range from 0 to 255.

(a) Write a MATLAB code to find a matrix W0, an approximation of W , out of Aw .

(b) Display the images represented by Aw   and W0  side by side using  subplot.  Do they look

similar to their respective original images in Figure 2?