-
Notifications
You must be signed in to change notification settings - Fork 0
/
elbp.py
47 lines (40 loc) · 1.25 KB
/
elbp.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
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
import pandas as pd
import skimage.feature
def get_elbp_df(images):
elbp_df=[]
for image in images:
rotation_invariant_lbp = skimage.feature.local_binary_pattern(
image,
P=8,
R=2,
method='ror'
)
lbp_ror_histogram, _ = np.histogram(
rotation_invariant_lbp,
bins=10
)
lbp_ror_variance = np.var(rotation_invariant_lbp)
lbp_ror_histogram=lbp_ror_histogram/lbp_ror_variance
norm = np.linalg.norm(lbp_ror_histogram)
normal_lbp_ror_histogram = lbp_ror_histogram/norm
elbp_df.append(normal_lbp_ror_histogram)
print('here')
return pd.DataFrame(
np.array(elbp_df, dtype=np.float32)
)
def get_elbp_vector(image):
rotation_invariant_lbp = skimage.feature.local_binary_pattern(
image,
P=8,
R=2,
method='ror'
)
return np.array(rotation_invariant_lbp, dtype=np.float32)
# lbp_ror_histogram, _ = np.histogram(
# rotation_invariant_lbp,
# bins=10
# )
# norm = np.linalg.norm(lbp_ror_histogram)
# normal_lbp_ror_histogram = lbp_ror_histogram / norm
# return np.array(normal_lbp_ror_histogram, dtype=np.float32).ravel()