From ca969217d6512b175f6a63d36e3ac34c0e610d2f Mon Sep 17 00:00:00 2001 From: Tomas Musil Date: Wed, 25 Jun 2014 01:58:02 +0200 Subject: [PATCH] refactor linef --- imago | 2 +- imago_pack/linef.py | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) 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" -- 2.4.2