-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhog.py
36 lines (34 loc) · 918 Bytes
/
hog.py
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
30
31
32
33
34
35
36
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import skimage.feature
def get_hog_df(images):
# creating hog features
hog_df=[]
for image in images:
hog_vector = skimage.feature.hog(
image,
orientations=9,
pixels_per_cell=(8, 8),
cells_per_block=(2, 2),
visualize=False,
multichannel=False
)
hog_df.append(hog_vector)
return pd.DataFrame(np.array(
hog_df,
dtype=np.float32
))
def get_hog_vector(image):
hog_vector, hog_image = skimage.feature.hog(
image,
orientations=9,
pixels_per_cell=(8, 8),
cells_per_block=(2, 2),
visualize=True,
multichannel=False
)
return {
'hog_vector': np.array(hog_vector, dtype=np.float32).ravel(),
'hog_image': np.array(hog_image, dtype=np.float32)
}