diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-01 14:18:20 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-09-01 14:18:20 +0300 |
commit | e2f39e528626d3c6093e4e0490e1337d9bf7ff84 (patch) | |
tree | ab07943349cd597ab23c715d7647c4fe236ecb2a | |
parent | more useful help messages + README update (diff) | |
download | filters-e2f39e528626d3c6093e4e0490e1337d9bf7ff84.tar.gz filters-e2f39e528626d3c6093e4e0490e1337d9bf7ff84.zip |
code style
Diffstat (limited to '')
-rw-r--r-- | filters/kernel/shift.py | 26 |
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)) |