more refactoring on linef
authorTomas Musil <tomik.musil@gmail.com>
Wed, 25 Jun 2014 00:20:29 +0000 (02:20 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Wed, 25 Jun 2014 00:20:29 +0000 (02:20 +0200)
imago_pack/linef.py

index 03de6bd..5eaa0d1 100644 (file)
@@ -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"