X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/fd9a681b1e6fb94684bbfacea2b933ecae1c68ed..45b6aba3bbf3aea1bacad077387ae77a1deb1a3c:/imago_pack/linef.py diff --git a/imago_pack/linef.py b/imago_pack/linef.py index fb83db4..47952c2 100644 --- a/imago_pack/linef.py +++ b/imago_pack/linef.py @@ -13,13 +13,12 @@ except ImportError, msg: import filters from hough import Hough -def prepare(image, show_image, verbose): +def prepare(image, show_image, logger): # TODO comment im_l = image.convert('L') show_image(im_l, "ITU-R 601-2 luma transform") - if verbose: - print >> sys.stderr, "edge detection" + logger("edge detection") im_edges = filters.edge_detection(im_l) show_image(im_edges, "edge detection") @@ -34,8 +33,7 @@ def transform(image, hough, show_image): show_image(im_hough, "hough transform") # im_hough.image = filters.peaks(im_hough.image) - # if show_all: - # do_something(im_hough.image, "peak extraction") + # show_image(im_hough.image, "peak extraction") im_h2 = filters.high_pass(im_hough, 96) show_image(im_h2, "second high pass filters") @@ -45,34 +43,22 @@ def transform(image, hough, show_image): return im_h2 -def find_lines(image, show_all, do_something, verbose): +def find_lines(image, show_image, logger): """Find lines in the *image*.""" # TODO refactor into smaller functions - - def nothing(a, b): - pass - - if show_all: - show_image = do_something - else: - show_image = nothing - - if verbose: - print >> sys.stderr, "preprocessing" - + + logger("preprocessing") show_image(image, "original image") - im_h = prepare(image, show_image, verbose) + im_h = prepare(image, show_image, logger) hough = Hough.default(im_h) - if verbose: - print >> sys.stderr, "hough transform" + logger("hough transform") im_h2 = transform(im_h, hough, show_image) - if verbose: - print >> sys.stderr, "second hough transform" + logger("second hough transform") # im_hough might be used instead im_h2, but at the moment it brings a lot of # noise to the second transform, which later confuses the center-finding @@ -87,8 +73,7 @@ def find_lines(image, show_all, do_something, verbose): im_h3 = filters.components(im_h3) show_image(im_h3, "half centers") - if verbose: - print >> sys.stderr, "finding the grid" + logger("finding the lines") lines_m = hough2.all_lines_h(im_h3) lines = []