From cc6537b2281a088448df73bfc3d7aec5ab80f1dc Mon Sep 17 00:00:00 2001 From: melissawm Date: Fri, 21 Feb 2020 11:39:18 -0300 Subject: Added plot scripts and reworded to respond to PR comments. --- doc/source/user/plot_reconstructed.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 doc/source/user/plot_reconstructed.py (limited to 'doc/source/user/plot_reconstructed.py') diff --git a/doc/source/user/plot_reconstructed.py b/doc/source/user/plot_reconstructed.py new file mode 100644 index 000000000..37cf3c626 --- /dev/null +++ b/doc/source/user/plot_reconstructed.py @@ -0,0 +1,17 @@ +from scipy import misc +import matplotlib.pyplot as plt +import numpy as np +from numpy import linalg + +img = misc.face() +img_array = img / 255 +img_array_transposed = np.transpose(img_array, (2, 0, 1)) + +U, s, Vt = linalg.svd(img_array_transposed) + +Sigma = np.zeros((3, 768, 1024)) +for j in range(3): + np.fill_diagonal(Sigma[j, :, :], s[j, :]) + +reconstructed = U @ Sigma @ Vt +plt.imshow(np.transpose(reconstructed, (1, 2, 0))) -- cgit v1.2.1