Adds plots

main
Spagnolo Gasper 2022-12-29 10:47:27 +01:00
parent 2cfc29de10
commit 94d4358fab
16 changed files with 16 additions and 14 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

View File

@ -42,7 +42,6 @@ def one_d() -> None:
U, S, VT, _ = uz_image.compute_PCA(points)
uz_image.plot_histogram_pca(U, S, VT)
# U is the matrix of eigenvectors
# S is the vector of eigenvalues
@ -234,21 +233,24 @@ def three_b():
img2 = imgs[0].copy()
fig, axs = plt.subplots(5, 2)
for i in range(5):
# Project image into PCA subspace
y_i = np.matmul(img2 - mean, U)
y_i[0] = 0
y_i[i] = 0
# Project image back into original subspace
x_i = np.matmul(y_i, U.T) + mean
# Plot the original image and the projected images
diff = (np.sum(np.abs(img - x_i)))
fig, axs = plt.subplots(1, 2)
fig.suptitle(f'Add noise in PCA space, diff: {np.round(diff, 2)}')
axs[0].imshow(img2.reshape((96, 84)), cmap='gray')
axs[1].imshow(x_i.reshape((96, 84)), cmap='gray')
plt.show()
axs[i, 0].imshow(img2.reshape((96, 84)).copy(), cmap='gray')
axs[i, 1].imshow(x_i.reshape((96, 84)).copy(), cmap='gray')
axs[i, 1].set(title=f'Add noise in PCA space y[{i}], diff: {np.round(diff, 2)}')
plt.show()
def three_c():
"""
Effect of the number of components on the reconstruction: Take a random
@ -430,7 +432,7 @@ def main():
#one_f()
#two_b()
#three_a()
#three_b()
three_b()
#three_c()
#three_d()
#three_e()

BIN
assignment6/video.avi Normal file

Binary file not shown.