summaryrefslogtreecommitdiff
path: root/doc/source/user/plot_final.py
diff options
context:
space:
mode:
Diffstat (limited to 'doc/source/user/plot_final.py')
-rw-r--r--doc/source/user/plot_final.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/doc/source/user/plot_final.py b/doc/source/user/plot_final.py
new file mode 100644
index 000000000..10cb097dd
--- /dev/null
+++ b/doc/source/user/plot_final.py
@@ -0,0 +1,19 @@
+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, :])
+
+k = 10
+
+approx_img = U @ Sigma[..., :k] @ Vt[..., :k, :]
+plt.imshow(np.transpose(approx_img, (1, 2, 0)))