refactored image component filters
[imago.git] / imago_pack / intrsc.py
index 45308b1..9fabcd5 100644 (file)
@@ -1,10 +1,11 @@
-"""Imago intersections module"""
+"""Imago intersections module."""
 
 from math import cos, tan, pi
 from operator import itemgetter
 
 import ImageDraw
 
+import filters
 import k_means
 import output
 
@@ -25,6 +26,7 @@ def dst_sort(lines):
 
 def board(image, lines, show_all, do_something):
     """Compute intersections, find stone colors and return board situation."""
+    # TODO refactor show_all, do_something
     lines = [dst_sort(l) for l in lines]
     intersections = intersections_from_angl_dist(lines, image.size)
 
@@ -36,10 +38,14 @@ def board(image, lines, show_all, do_something):
                 draw.point((x , y), fill=(120, 255, 120))
         do_something(image_g, "intersections")
 
+    image_c = filters.color_enhance(image)
+    if show_all:
+        do_something(image_c, "white balance")
+    
     board_raw = []
     
     for line in intersections:
-        board_raw.append([stone_color_raw(image, intersection) for intersection in
+        board_raw.append([stone_color_raw(image_c, intersection) for intersection in
                       line])
     board_raw = sum(board_raw, [])
 
@@ -95,6 +101,7 @@ def board(image, lines, show_all, do_something):
     return output.Board(19, board_r)
 
 def mean_luma(cluster):
+    """Return mean luma of the *cluster* of points."""
     return sum(c[0][0] for c in cluster) / float(len(cluster))
 
 def intersections_from_angl_dist(lines, size, get_all=True):