projekty
/
imago.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor logger in linef
[imago.git]
/
imago_pack
/
linef.py
diff --git
a/imago_pack/linef.py
b/imago_pack/linef.py
index
77383b7
..
667442c
100644
(file)
--- a/
imago_pack/linef.py
+++ b/
imago_pack/linef.py
@@
-13,13
+13,12
@@
except ImportError, msg:
import filters
from hough import Hough
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")
# 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")
im_edges = filters.edge_detection(im_l)
show_image(im_edges, "edge detection")
@@
-47,23
+46,26
@@
def transform(image, hough, show_image):
def find_lines(image, show_image, verbose):
"""Find lines in the *image*."""
# TODO refactor into smaller functions
def find_lines(image, show_image, verbose):
"""Find lines in the *image*."""
# TODO refactor into smaller functions
-
+
if verbose:
if verbose:
- print >> sys.stderr, "preprocessing"
-
+ def logger(m):
+ print >> sys.stderr, m
+ else:
+ def logger(m):
+ pass
+
+ logger("preprocessing")
show_image(image, "original image")
show_image(image, "original image")
- im_h = prepare(image, show_image,
verbose
)
+ im_h = prepare(image, show_image,
logger
)
hough = Hough.default(im_h)
hough = Hough.default(im_h)
- if verbose:
- print >> sys.stderr, "hough transform"
+ logger("hough transform")
im_h2 = transform(im_h, hough, show_image)
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
# 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
@@
-78,8
+80,7
@@
def find_lines(image, show_image, verbose):
im_h3 = filters.components(im_h3)
show_image(im_h3, "half centers")
im_h3 = filters.components(im_h3)
show_image(im_h3, "half centers")
- if verbose:
- print >> sys.stderr, "finding the grid"
+ logger("finding the grid")
lines_m = hough2.all_lines_h(im_h3)
lines = []
lines_m = hough2.all_lines_h(im_h3)
lines = []