-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLBP_generator.py
32 lines (29 loc) · 913 Bytes
/
LBP_generator.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#==========================================
# Title : 1D-LBP Pattern Generator
# Author: pranabendra
# Date : 11 Feb 2019
#==========================================
# -*- coding: utf-8 -*-
def generate(window_size):
def count_transition(num, window_size):
d = ('{0:0'+str(window_size)+'b}').format(num)
#print(d)
b = num >> 1
k = d[0] + ('{0:0'+str(window_size - 1)+'b}').format(b)
#print(k)
e = int(k,2)
c = num ^ e
#print(bin(c))
return ('{0:0'+str(window_size)+'b}').format(c).count('1');
count = 0
ref = []
for i in range(2**window_size):
if count_transition(i, window_size) <= 2:
count += 1
ref.append(i)
#print(i)
#print(count)
assert(count == len(ref))
return count, ref;