-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextractor.py
More file actions
58 lines (42 loc) · 1.44 KB
/
extractor.py
File metadata and controls
58 lines (42 loc) · 1.44 KB
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
57
import watchman
from SimpleCV import Image, Color, EdgeHistogramFeatureExtractor, HueHistogramFeatureExtractor, MorphologyFeatureExtractor, np
def diff():
current = watchman.imgbank[0]
if len(imgbank) > 1:
older = watchman.imgbank[1]
else:
older = current
diff = current - older
matrix = diff.getNumpy()
mean = matrix.mean()
return mean
def hue():
hue = HueHistogramFeatureExtractor()
a = np.array(hue.extract(watchman.imgbank[0]))
if len(watchman.imgbank) > 1:
b = np.array(hue.extract(watchman.imgbank[1]))
else:
b = np.array(hue.extract(watchman.imgbank[0]))
AandB = np.sum(np.square(a-b))
return AandB
def myBinaryFunc(input):
return input.binarize().erode()
def morph():
mf = MorphologyFeatureExtractor()
mf.setThresholdOperation(myBinaryFunc)
a = np.array(mf.extract(watchman.imgbank[0]))
if len(watchman.imgbank) > 1:
b = np.array(mf.extract(watchman.imgbank[1]))
else:
b = np.array(mf.extract(watchman.imgbank[0]))
AandB = np.sum(np.square(a-b))
return AandB
def edge():
edgeFeats = EdgeHistogramFeatureExtractor()
a = np.array(edgeFeats.extract(watchman.imgbank[0]))
if len(watchman.imgbank) > 1:
b = np.array(edgeFeats.extract(watchman.imgbank[1]))
else:
b = np.array(edgeFeats.extract(watchman.imgbank[0]))
AandB = np.sum(np.square((a-b)))
return AandB