-
Notifications
You must be signed in to change notification settings - Fork 2
/
Kernels.py
70 lines (59 loc) · 1.96 KB
/
Kernels.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
57
58
59
60
61
62
63
64
65
66
67
import numpy as np
class kernel():
FULL_KERNEL_3 = np.ones((3, 3), np.uint8)
FULL_KERNEL_5 = np.ones((5, 5), np.uint8)
FULL_KERNEL_7 = np.ones((7, 7), np.uint8)
FULL_KERNEL_9 = np.ones((9, 9), np.uint8)
FULL_KERNEL_31 = np.ones((31, 31), np.uint8)
def cross_kernel_3(self):
self.CROSS_KERNEL_3 = np.asarray(
[
[0, 1, 0],
[1, 1, 1],
[0, 1, 0],
], dtype=np.uint8)
return self.CROSS_KERNEL_3
def cross_kernel_5(self):
self.CROSS_KERNEL_5 = np.asarray(
[
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
[1, 1, 1, 1, 1],
[0, 0, 1, 0, 0],
[0, 0, 1, 0, 0],
], dtype=np.uint8)
return self.CROSS_KERNEL_5
def diamond_kernel_5(self):
self.DIAMOND_KERNEL_5 = np.array(
[
[0, 0, 1, 0, 0],
[0, 1, 1, 1, 0],
[1, 1, 1, 1, 1],
[0, 1, 1, 1, 0],
[0, 0, 1, 0, 0],
], dtype=np.uint8)
return self.DIAMOND_KERNEL_5
def cross_kernel_7(self):
self.CROSS_KERNEL_7 = np.asarray(
[
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
], dtype=np.uint8)
return self.CROSS_KERNEL_7
def diamond_kernel_7(self):
self.DIAMOND_KERNEL_7 = np.asarray(
[
[0, 0, 0, 1, 0, 0, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 0],
[0, 0, 0, 1, 0, 0, 0],
], dtype=np.uint8)
return self.DIAMOND_KERNEL_7