From: Tomas Musil Date: Wed, 25 Jun 2014 00:20:29 +0000 (+0200) Subject: more refactoring on linef X-Git-Url: http://git.tomasm.cz/imago.git/commitdiff_plain/f66ba63b152a265d8876cb1c82dc7ace7ce5f10a more refactoring on linef --- diff --git a/imago_pack/linef.py b/imago_pack/linef.py index 03de6bd..5eaa0d1 100644 --- a/imago_pack/linef.py +++ b/imago_pack/linef.py @@ -31,6 +31,24 @@ def prepare(image, show_all, do_something, verbose): return im_h +def transform(image, hough, show_all, do_something): + im_hough = hough.transform(image) + if show_all: + do_something(im_hough, "hough transform") + + # im_hough.image = filters.peaks(im_hough.image) + # if show_all: + # do_something(im_hough.image, "peak extraction") + + im_h2 = filters.high_pass(im_hough, 96) + if show_all: + do_something(im_h2, "second high pass filters") + + im_h2 = filters.components2(im_h2) + if show_all: + do_something(im_h2, "components centers") + + return im_h2 def find_lines(image, show_all, do_something, verbose): """Find lines in the *image*.""" @@ -43,28 +61,13 @@ def find_lines(image, show_all, do_something, verbose): do_something(image, "original image") im_h = prepare(image, show_all, do_something, verbose) - hough = Hough.default(im_h) if verbose: print >> sys.stderr, "hough transform" - - im_hough = hough.transform(im_h) - if show_all: - do_something(im_hough, "hough transform") - - # im_hough.image = filters.peaks(im_hough.image) - # if show_all: - # do_something(im_hough.image, "peak extraction") - - im_h2 = filters.high_pass(im_hough, 96) - if show_all: - do_something(im_h2, "second high pass filters") - - im_h2 = filters.components2(im_h2) - if show_all: - do_something(im_h2, "components centers") + + im_h2 = transform(im_h, hough, show_all, do_something) if verbose: print >> sys.stderr, "second hough transform"