Projects & Blogs
PROBABLISTIC APPR...
MINI-UNET
MINI-ALEXNET
SEQUENTIAL MONTE ...
TRUNCATED SVD
CUSTOM DATALOADER...
PROBABILITY
import numpy as np
import matplotlib.pyplot as plt
import cv2
img = cv2.cvtColor(cv2.imread('sample.jpg'),cv2.COLOR_RGB2GRAY)
X = np.array(img)
r = np.linalg.matrix_rank(img)
U, sigma, V = np.linalg.svd(X, full_matrices=True)
print(f'Image Shape : {X.shape}')
print('Image Intital Decomposition Information')
print(f'U : {U.shape}')
print(f'S : {sigma.shape}')
print(f'V : {V.shape}')
ranks = [5, 10, 15, 25, 50, r]
R = len(ranks)
for i in range(R):
k = ranks[i]
x_hat = np.dot(np.dot(U[:, :k], np.diag(sigma[:k])), V[:k, :])
plt.subplot(2, 3, i + 1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(x_hat, cmap='gray')
plt.title("rank {}".format(k))
plt.show()
Image Shape : (900, 600)
Image Intital Decomposition Information
U : (900, 900)
S : (600,)
V : (600, 600)