aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-01-22 09:45:29 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-01-22 09:45:29 +0300
commit9aa3f2de19adc2ed2affde008e1252cbc6e1d67e (patch)
tree2040fda4b9dbb979866d9f6a13a8c0a4a6aa9e49 /bin
parentrevert most of the recent Pylint fixes (diff)
downloadfilters-9aa3f2de19adc2ed2affde008e1252cbc6e1d67e.tar.gz
filters-9aa3f2de19adc2ed2affde008e1252cbc6e1d67e.zip
fix Pylint warnings
Diffstat (limited to 'bin')
-rw-r--r--bin/box_blur.py17
-rw-r--r--bin/gaussian_blur.py17
-rw-r--r--bin/shift.py17
3 files changed, 30 insertions, 21 deletions
diff --git a/bin/box_blur.py b/bin/box_blur.py
index d570f5a..24440af 100644
--- a/bin/box_blur.py
+++ b/bin/box_blur.py
@@ -6,13 +6,14 @@
import argparse
import sys
-from .utils import cmd_line, image
from filters.convolution import convolve
from filters.kernel.box_blur import gen_kernel
+from .utils import cmd_line, image
+
DEFAULT_RADIUS = 1
-def _main_box_blur(img_path, radius=DEFAULT_RADIUS, output_path=None):
+def do_box_blur(img_path, radius=DEFAULT_RADIUS, output_path=None):
img = image.load_grayscale(img_path)
kernel = gen_kernel(radius)
output = convolve(img, kernel)
@@ -21,7 +22,9 @@ def _main_box_blur(img_path, radius=DEFAULT_RADIUS, output_path=None):
else:
image.save(output_path, output)
-def _parse_args(args=sys.argv):
+def _parse_args(args=None):
+ if args is None:
+ args = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Apply box blur to an image.')
parser.add_argument('img_path', help='source image file path')
@@ -31,10 +34,10 @@ def _parse_args(args=sys.argv):
type=cmd_line.parse_non_negative_integer,
default=DEFAULT_RADIUS,
help='specify convolution kernel radius')
- return parser.parse_args(args[1:])
+ return parser.parse_args(args)
-def _main(args=sys.argv):
- _main_box_blur(**vars(_parse_args(args)))
+def main(args=None):
+ do_box_blur(**vars(_parse_args(args)))
if __name__ == '__main__':
- _main()
+ main()
diff --git a/bin/gaussian_blur.py b/bin/gaussian_blur.py
index c2aa79a..f6f01a5 100644
--- a/bin/gaussian_blur.py
+++ b/bin/gaussian_blur.py
@@ -6,14 +6,15 @@
import argparse
import sys
-from .utils import cmd_line, image
from filters.convolution import convolve
from filters.kernel.gaussian_blur import gen_kernel
+from .utils import cmd_line, image
+
DEFAULT_SIGMA = 1.
DEFAULT_RADIUS = 1
-def _main_gaussian_blur(
+def do_gaussian_blur(
img_path, radius=DEFAULT_RADIUS, sigma=DEFAULT_SIGMA,
output_path=None):
@@ -25,7 +26,9 @@ def _main_gaussian_blur(
else:
image.save(output_path, output)
-def _parse_args(args=sys.argv):
+def _parse_args(args=None):
+ if args is None:
+ args = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Apply Gaussian blur to an image.')
parser.add_argument('img_path', help='source image file path')
@@ -38,10 +41,10 @@ def _parse_args(args=sys.argv):
type=cmd_line.parse_non_negative_integer,
default=DEFAULT_RADIUS,
help='specify convolution kernel radius')
- return parser.parse_args(args[1:])
+ return parser.parse_args(args)
-def _main(args=sys.argv):
- _main_gaussian_blur(**vars(_parse_args(args)))
+def main(args=None):
+ do_gaussian_blur(**vars(_parse_args(args)))
if __name__ == '__main__':
- _main()
+ main()
diff --git a/bin/shift.py b/bin/shift.py
index 94db333..1b8c25a 100644
--- a/bin/shift.py
+++ b/bin/shift.py
@@ -6,14 +6,15 @@
import argparse
import sys
-from .utils import cmd_line, image
from filters.convolution import convolve
from filters.kernel.shift import Direction
+from .utils import cmd_line, image
+
DEFAULT_DIRECTION = Direction.SOUTH_EAST
DEFAULT_DISTANCE = 1
-def _main_shift(
+def do_shift(
img_path, direction=DEFAULT_DIRECTION, distance=DEFAULT_DISTANCE,
output_path=None):
@@ -31,7 +32,9 @@ def _parse_direction(s):
except ValueError:
raise argparse.ArgumentTypeError('invalid direction: ' + s)
-def _parse_args(args=sys.argv):
+def _parse_args(args=None):
+ if args is None:
+ args = sys.argv[1:]
parser = argparse.ArgumentParser(
description='Shift an image by a few pixels in a specified direction.')
parser.add_argument('img_path', help='source image file path')
@@ -44,10 +47,10 @@ def _parse_args(args=sys.argv):
type=cmd_line.parse_non_negative_integer,
default=DEFAULT_DISTANCE,
help='specify shift size (in pixels)')
- return parser.parse_args(args[1:])
+ return parser.parse_args(args)
-def _main(args=sys.argv):
- _main_shift(**vars(_parse_args(args)))
+def main(args=None):
+ do_shift(**vars(_parse_args(args)))
if __name__ == '__main__':
- _main()
+ main()