-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathimages_to_matrix.py
More file actions
executable file
·29 lines (19 loc) · 681 Bytes
/
images_to_matrix.py
File metadata and controls
executable file
·29 lines (19 loc) · 681 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
28
29
import cv2
import numpy as np
class images_to_matrix_class:
def __init__(self, images_name, img_width, img_height):
self.images_name = images_name
self.img_width = img_width
self.img_height = img_height
self.img_size = (img_width * img_height)
def get_matrix(self):
col = len(self.images_name)
img_mat = np.zeros((self.img_size, col))
i = 0
for name in self.images_name:
gray = cv2.imread(name, 0)
gray = cv2.resize(gray, (self.img_height, self.img_width))
mat = np.asmatrix(gray)
img_mat[:, i] = mat.ravel()
i += 1
return img_mat