1.MATH347 Homework 3
Topic: |
SVD identification of artwork features |
Post date: |
May 27, 2025 |
Due date: |
May 28, 2025 |
1.1.Background
This homework investigates consequences of the fundamental theorem of
algebra and application of the singular value decomposition.
1.2.Theoretical questions
Consider a linear mapping ,
from vector space with basis , to , with basis .
-
Is a basis for ?
(1 point)
-
If must ? (1 point)
-
If
and
for ,
what is the matrix representing
? (2 points)
-
Determine the singular value decomposition and pseudo-inverse of a
matrix
(i.e., a row vector). (2 points)
1.3.Ordered bases for the fundamental spaces
and painting motifs
1.3.1.Introduction
The fudamental theorem of linear algebra partitions the domain and
codomain of a linear mapping. The singular value decomposition provides
orthogonal bases for each of the subspaces arising in the partition. The
bases are ordered according to the amplification behavior of the linear
mapping, expressed through the norm of successive restrictions of the
mapping. This approach is closely aligned with typical problems in data
science, and can be used in a variety of scenarios. In this homework
linear algebra methods will first be used in a field far removed from
the physical sciences: extracting the quirks of painter style from the
overall composition of a painting, and applying one artist's style to
another artist's composition. This is often-encountered data science
problem: distinguishing between small and large scale features of data.
∴ |
mkpath(homedir()*"/courses/MATH347DS/homework/hw03"); |
∴ |
cd(homedir()*"/courses/MATH347DS/homework/hw03"); |
Load an image, transform it to a matrix, note the image size, and
compute the SVD of the matrix.
∴ |
imFK96=Gray.(load("./paintings/Frida_Kahlo_96.jpg")); |
∴ |
norm(AFK96-F.U*Diagonal(F.S)*F.Vt) |
Load another image, select a portion of the same size as previous image
and compute its SVD.
∴ |
imVvG95=Gray.(load("./paintings/Vincent_van_Gogh_95.jpg")); |
∴ |
AVvG95=Real.(imVvG95)[1:mx,1:my]; |
Note that the singular values of the two images decay rapidly
∴ |
clf(); plot(1:my,F.S,".b",1:my,G.S,".r"); xlabel("i"); ylabel(L"$\sigma_i$"); |
∴ |
savefig("hw03f01.eps"); |
 |
|
Figure 1. Singular values
of the two images.
|
Generate a new image by combining the large-scale features of the first
image and the small-scale features of the second. Choose the new image
to reflect 70% (
of the composition of the first image and 30% ()
of the small-scale features of the second. Choose large scale features
of the first image to include rank-1 updates from 1 to .
Choose small scale features of the second image to include rank-1
updates from to
.
∴ |
x1=0.3; x2=0.7; kA=40; kB=80; lB=120; |
Form the large-scale features from first image. Note that Vt
contains the transposed matrix.
∴ |
A1 = F.U[:,1:kA]*Diagonal(F.S[1:kA])*F.Vt[1:kA,:]; |
Form the small-scale features from second image
∴ |
B1 = G.U[:,kB:lB]*Diagonal(G.S[kB:lB])*G.Vt[kB:lB,:]; |
Combine the two to obtain a new image, display the images and save
them.
∴ |
figure(1); clf(); imshow(A1,cmap="gray"); savefig("hw03A1.png"); |
∴ |
figure(2); clf(); imshow(B1,cmap="gray"); savefig("hw03B1.png"); |
∴ |
figure(3); clf(); imshow(Anew,cmap="gray"); savefig("hw03Anew.png"); |
|
|
Figure 2. A new painting (right) reflecting
the composition of the Frida Kahlo self portrait (left) with the
brush stroke extracted from the Vincent van Gogh self-portrait
(middle).
|
1.3.2.Tasks
Generate 4 different new paintings (3 points each) experimenting with
various images as presented above. Comment each result.