Transform the MATH661/images/Frida_Kahlo_96.png image, Fig. 1, into
a matrix of gray scale values.
Compute the SVD of .
Define
Represent as images
for
Comment on what you observe.
|
|
Figure 1. Images to be represented as
matrices
|
Solution.
Julia (1.6.1) session in GNU TeXmacs
∴ |
using Images, FileIO, ImageIO |
Import an image
∴ |
pre="/home/student/courses/MATH661/images/"; |
∴ |
im=load(pre*"Frida_Kahlo_96.png"); |
∴ |
im2=load(pre*"Georges_Seurat_3.png"); |
Convert image to an array of floats, and display the result
Compute the SVD of the array of floats obtained from the image
Define a function to sum the first
rank-one updates from an SVD
∴ |
function rsvd(p,U,S,V)
B = S[1]*U[:,1]*V[:,1]'
for k=2:p
B = B + S[k]*U[:,k]*V[:,k]'
end
return B
end; |
∴ |
function lsvd(q,U,S,V)
r=minimum(size(U));
B = S[r]*U[:,r]*V[:,r]'
for k=r-q:r-1
B = B + S[k]*U[:,k]*V[:,k]'
end
return B
end; |
Create a matrix with the first 10 rank-one updates, and display it.
∴ |
imshow(B+C,cmap="gray"); |
Transform the MATH661/images/Georges_Seurat_3.png image, Fig. 1,
into a matrix of gray scale
values. Compute the SVD of .
Let .
Define
Represent as images
for
Comment on what you observe.