/
index.py
56 lines (44 loc) · 1.19 KB
/
index.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
48
49
50
51
52
53
54
55
56
# import the necessary packages
from colordescriptor import ColorDescriptor
import os
import matplotlib.pyplot as plt
from datetime import datetime as d
# initialize the color descriptor
cd = ColorDescriptor()
dir_images = 'Corel'
imgs = os.listdir(dir_images)
# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)
# Store imageID and LBP features
output = open("lbp_value.csv", "w")
for imgnm in imgs:
img_rgb = plt.imread(os.path.join(dir_images,imgnm))
imageID = imgnm
features = cd.calculate_lbp(img_rgb)
# write the features to file
features = [str(f) for f in features]
output.write("%s,%s\n" % (imageID, ",".join(features)))
output.close()
# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)
# Store imageID and BEM features
i = 0
output = open("bem_value.csv", "w")
for imgnm in imgs:
img_rgb = plt.imread(os.path.join(dir_images,imgnm))
imageID = imgnm
features = cd.calculate_lbp(img_rgb)
# write the features to file
features = [str(f) for f in features]
output.write("%s,%s\n" % (imageID, ",".join(features)))
i= i+1
print(i)
output.close()
# Set the timer
now = d.now()
current = now.strftime("%H:%M:%S")
print(current)