![]()
MATH347 L26: SVD applications
|
New concepts:
Extracting large scale and small scale features from data
Image processing
Image composition
Generating art from algorithms
![]()
Computer generated visual arts
|
Tate Modern Gallery in London: Electric Dreams exhibition
Art related to mathematics has a long history
M.C. Escher
![]()
Analysis of paintings
|
A distinction is made in the visual arts between composition and technique
|
|
|
|
|
|
|
|
|
![]()
Matlab/Octave code
|
Read an image from which large-scale features will be extracted, the painting composition. Find its size, and transform from color to gray scale image and then to a matrix of real-valued components
>> |
im1=imread("./courses/MATH347/paintings/Andy_Warhol_2.jpg"); |
>> |
im1BW=rgb2gray(im1); [px,py,nc]=size(im1); [px py nc] |
>> |
A1=im2double(im1BW); |
>> |
imwrite(im1BW,"./courses/MATH347/paintings/im1BW.jpg"); |
>> |
![]()
Matlab/Octave code
|
Read a portion of another image of the same size as the first image. Small-scale features will be extracted from this second image, the painting brushwork style
>> |
im2=imread("./courses/MATH347/paintings/Vincent_van_Gogh_95.jpg"); |
>> |
im2BW=rgb2gray(im2); [qx,qy,nc]=size(im2); [qx qy nc] |
>> |
A2=im2double(im2BW); |
>> |
imwrite(im2BW,"./courses/MATH347/paintings/im2BW.jpg"); |
>> |
![]()
Matlab/Octave code
|
Compute the SVDs of the matrices whose components are the grayscale intensity values of the image
>> |
[U1,S1,V1]=svd(A1); [U2,S2,V2]=svd(A2(1:px,1:py)); |
Form a new image from the first modes of the composition image and modes from to of the brushstyle image. Weight the contribution of the large-scale and small-scale features by with
>> |
j=25; k=50; l=75; w1=0.25; w2=0.75; |
>> |
composition = w1*U1(:,1:j)*S1(1:j,1:j)*V1(:,1:j)'; |
>> |
style = w2*U2(:,k:l)*S2(k:l,k:l)*V2(:,k:l)'; |
>> |
newimage = rescale(composition + style); |
>> |
imwrite(newimage,"./courses/MATH347/paintings/newimage.jpg"); |
>> |