From: Tomas Musil Date: Tue, 24 Jun 2014 23:58:02 +0000 (+0200) Subject: refactor linef X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/ca969217d6512b175f6a63d36e3ac34c0e610d2f?ds=sidebyside;hp=ea124bf748e7ade121ce5b642a311fe7bbbd70c3 refactor linef --- diff --git a/imago b/imago index 78a81e6..968faa1 100755 --- a/imago +++ b/imago @@ -1,6 +1,6 @@ #!/usr/bin/env python -"""Go image recognition""" +"""Go image recognition.""" from imago_pack import imago diff --git a/imago_pack/linef.py b/imago_pack/linef.py index 06483a3..b098257 100644 --- a/imago_pack/linef.py +++ b/imago_pack/linef.py @@ -13,23 +13,14 @@ except ImportError, msg: import filters from hough import Hough -def find_lines(image, show_all, do_something, verbose): - """Find lines in the *image*.""" - # TODO refactor into smaller functions - - if verbose: - print >> sys.stderr, "preprocessing" - - if show_all: - do_something(image, "original image") - +def prepare(image, show_all, do_something, verbose): + # TODO comment im_l = image.convert('L') if show_all: do_something(im_l, "ITU-R 601-2 luma transform") if verbose: print >> sys.stderr, "edge detection" - im_edges = filters.edge_detection(im_l) if show_all: do_something(im_edges, "edge detection") @@ -37,7 +28,22 @@ def find_lines(image, show_all, do_something, verbose): im_h = filters.high_pass(im_edges, 100) if show_all: do_something(im_h, "high pass filters") - + + return im_h + + +def find_lines(image, show_all, do_something, verbose): + """Find lines in the *image*.""" + # TODO refactor into smaller functions + + if verbose: + print >> sys.stderr, "preprocessing" + + if show_all: + do_something(image, "original image") + + im_h = prepare(image, show_all, do_something, verbose) + if verbose: print >> sys.stderr, "hough transform"