aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.pylintrc32
-rw-r--r--bin/box_blur.py17
-rw-r--r--bin/gaussian_blur.py17
-rw-r--r--bin/shift.py17
4 files changed, 30 insertions, 53 deletions
diff --git a/.pylintrc b/.pylintrc
index 5ff2744..f22f1b5 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -1,39 +1,7 @@
[MESSAGES CONTROL]
-#disable=old-ne-operator,filter-builtin-not-iterating,nonzero-method,long-builtin,unpacking-in-except,backtick,suppressed-message,setslice-method,round-builtin,coerce-builtin,input-builtin,raising-string,raw_input-builtin,apply-builtin,delslice-method,useless-suppression,hex-method,zip-builtin-not-iterating,range-builtin-not-iterating,intern-builtin,old-octal-literal,xrange-builtin,no-absolute-import,cmp-builtin,reduce-builtin,next-method-called,getslice-method,oct-method,reload-builtin,dict-view-method,file-builtin,long-suffix,parameter-unpacking,dict-iter-method,cmp-method,old-division,using-cmp-argument,buffer-builtin,old-raise-syntax,indexing-exception,unicode-builtin,unichr-builtin,coerce-method,basestring-builtin,map-builtin-not-iterating,metaclass-assignment,print-statement,import-star-module-level,standarderror-builtin,execfile-builtin
disable=bad-whitespace,duplicate-code,invalid-name,missing-docstring,multiple-statements
-[BASIC]
-
-#bad-functions=map,filter
-#good-names=i,j,k,ex,Run,_
-#bad-names=foo,bar,baz,toto,tutu,tata
-#name-group=
-#include-naming-hint=no
-#class-rgx=[A-Z_][a-zA-Z0-9]+$
-#class-name-hint=[A-Z_][a-zA-Z0-9]+$
-#module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-#module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
-#inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
-#inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
-#variable-rgx=[a-z_][a-z0-9_]{2,30}$
-#variable-name-hint=[a-z_][a-z0-9_]{2,30}$
-#const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
-#const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
-#function-rgx=[a-z_][a-z0-9_]{2,30}$
-#function-name-hint=[a-z_][a-z0-9_]{2,30}$
-#attr-rgx=[a-z_][a-z0-9_]{2,30}$
-#attr-name-hint=[a-z_][a-z0-9_]{2,30}$
-#argument-rgx=[a-z_][a-z0-9_]{2,30}$
-#argument-name-hint=[a-z_][a-z0-9_]{2,30}$
-#method-rgx=[a-z_][a-z0-9_]{2,30}$
-#method-name-hint=[a-z_][a-z0-9_]{2,30}$
-#class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
-#class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
-#no-docstring-rgx=^_
-#docstring-min-length=-1
-
[TYPECHECK]
-#ignored-modules=
ignored-modules=cv2
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()