-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.py
More file actions
27 lines (20 loc) · 678 Bytes
/
demo.py
File metadata and controls
27 lines (20 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import numpy as np
img = mpimg.imread(r'\afhq\train\cat\flickr_cat_000002.jpg')
print('This image is: ',type(img),
'with dimensions:', img.shape)
plt.imshow(img)
plt.show()
#PCA
#Mean Removal
n_image = img.copy()
red_mean = np.mean(n_image[:,:,0])
green_mean = np.mean(n_image[:,:,1])
blue_mean = np.mean(n_image[:,:,2])
for i in range(n_image.shape[0]):
for j in range(n_image.shape[1]):
n_image[i,j,0] = n_image[i,j,0] - red_mean
n_image[i,j,1] = n_image[i,j,1] - green_mean
n_image[i,j,2] = n_image[i,j,2] - blue_mean
n_transpose = n_image.T