refactor linef
authorTomas Musil <tomik.musil@gmail.com>
Tue, 24 Jun 2014 23:58:02 +0000 (01:58 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Tue, 24 Jun 2014 23:58:02 +0000 (01:58 +0200)
imago
imago_pack/linef.py

diff --git a/imago b/imago
index 78a81e6..968faa1 100755 (executable)
--- a/imago
+++ b/imago
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-"""Go image recognition"""
+"""Go image recognition."""
 
 from imago_pack import imago
 
index 06483a3..b098257 100644 (file)
@@ -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"