aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-09-01 14:18:20 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-09-01 14:18:20 +0300
commite2f39e528626d3c6093e4e0490e1337d9bf7ff84 (patch)
treeab07943349cd597ab23c715d7647c4fe236ecb2a
parentmore useful help messages + README update (diff)
downloadfilters-e2f39e528626d3c6093e4e0490e1337d9bf7ff84.tar.gz
filters-e2f39e528626d3c6093e4e0490e1337d9bf7ff84.zip
code style
-rw-r--r--filters/kernel/shift.py26
1 files changed, 9 insertions, 17 deletions
diff --git a/filters/kernel/shift.py b/filters/kernel/shift.py
index 4e1e497..b9e586b 100644
--- a/filters/kernel/shift.py
+++ b/filters/kernel/shift.py
@@ -19,26 +19,18 @@ class Direction(Enum):
def gen_kernel(self, distance):
radius = distance
+ r = radius
size = 2 * radius + 1
kernel = np.zeros((size, size))
- x, y = radius, radius
- if self is Direction.NORTH:
- x = -1
- elif self is Direction.NORTH_EAST:
- x, y = -1, 0
- elif self is Direction.EAST:
- y = 0
- elif self is Direction.SOUTH_EAST:
- x, y = 0, 0
- elif self is Direction.SOUTH:
- x = 0
- elif self is Direction.SOUTH_WEST:
- x, y = 0, -1
- elif self is Direction.WEST:
- y = -1
- elif self is Direction.NORTH_WEST:
- x, y = -1, -1
+ if self is Direction.NORTH: x, y = -1, r
+ elif self is Direction.NORTH_EAST: x, y = -1, 0
+ elif self is Direction.EAST: x, y = r, 0
+ elif self is Direction.SOUTH_EAST: x, y = 0, 0
+ elif self is Direction.SOUTH: x, y = 0, r
+ elif self is Direction.SOUTH_WEST: x, y = 0, -1
+ elif self is Direction.WEST: x, y = r, -1
+ elif self is Direction.NORTH_WEST: x, y = -1, -1
else:
raise NotImplementedError('unsupported direction: ' + str(self))