move modules to subdirectory
authorTomas Musil <tomik.musil@gmail.com>
Sat, 7 Sep 2013 11:54:23 +0000 (13:54 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Sat, 7 Sep 2013 11:54:23 +0000 (13:54 +0200)
21 files changed:
imago [new file with mode: 0755]
imago_pack/__init__.py [new file with mode: 0644]
imago_pack/camera.py [moved from camera.py with 100% similarity]
imago_pack/capture.py [moved from capture.py with 100% similarity]
imago_pack/cs.py [moved from cs.py with 100% similarity]
imago_pack/filters.py [moved from filters.py with 100% similarity]
imago_pack/geometry.py [moved from geometry.py with 100% similarity]
imago_pack/gridf.py [moved from gridf.py with 100% similarity]
imago_pack/gridf_analyzer.py [moved from gridf_analyzer.py with 100% similarity]
imago_pack/hough.py [moved from hough.py with 100% similarity]
imago_pack/im_debug.py [moved from im_debug.py with 100% similarity]
imago_pack/imago.py [moved from imago.py with 100% similarity]
imago_pack/intrsc.py [moved from intrsc.py with 82% similarity]
imago_pack/k_means.py [moved from k_means.py with 100% similarity]
imago_pack/lhs.py [moved from lhs.py with 100% similarity]
imago_pack/linef.py [moved from linef.py with 100% similarity]
imago_pack/manual.py [moved from manual.py with 100% similarity]
imago_pack/pso.py [moved from pso.py with 100% similarity]
imago_pack/sgf.py [moved from sgf.py with 100% similarity]
imago_pack/timer.py [moved from timer.py with 100% similarity]
makefile

diff --git a/imago b/imago
new file mode 100755 (executable)
index 0000000..78a81e6
--- /dev/null
+++ b/imago
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+"""Go image recognition"""
+
+from imago_pack import imago
+
+imago.main()
diff --git a/imago_pack/__init__.py b/imago_pack/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
similarity index 100%
rename from camera.py
rename to imago_pack/camera.py
similarity index 100%
rename from capture.py
rename to imago_pack/capture.py
similarity index 100%
rename from cs.py
rename to imago_pack/cs.py
similarity index 100%
rename from filters.py
rename to imago_pack/filters.py
similarity index 100%
rename from geometry.py
rename to imago_pack/geometry.py
similarity index 100%
rename from gridf.py
rename to imago_pack/gridf.py
similarity index 100%
rename from hough.py
rename to imago_pack/hough.py
similarity index 100%
rename from im_debug.py
rename to imago_pack/im_debug.py
similarity index 100%
rename from imago.py
rename to imago_pack/imago.py
similarity index 82%
rename from intrsc.py
rename to imago_pack/intrsc.py
index 97f9987..445c447 100644 (file)
--- a/intrsc.py
@@ -43,18 +43,18 @@ def board(image, lines, show_all, do_something):
     board_raw = sum(board_raw, [])
 
     ### Show color distribution
     board_raw = sum(board_raw, [])
 
     ### Show color distribution
-    luma = [(0.30 * s[0] + 0.59 * s[1] + 0.11 * s[2]) / 255.
-                 for s in board_raw]
-    saturation = [(max(s) - min(s)) / (255 - abs(max(s) + min(s) - 255))
-                 for s in board_raw]
+    luma = [s[0] for s in board_raw]
+    saturation = [s[1] for s in board_raw]
+
     if show_all:
         import matplotlib.pyplot as pyplot
     if show_all:
         import matplotlib.pyplot as pyplot
-        pyplot.scatter(luma, saturation, color=[(s[0]/255., s[1]/255., s[2]/255., 1.) 
-                                            for s in board_raw])
+        pyplot.scatter(luma, saturation, 
+                       color=[(s[2][0]/255., s[2][1]/255., s[2][2]/255., 1.) 
+                              for s in board_raw])
         pyplot.show()
 
     clusters = k_means.cluster(3, 2,zip(zip(luma, saturation), range(len(luma))),
         pyplot.show()
 
     clusters = k_means.cluster(3, 2,zip(zip(luma, saturation), range(len(luma))),
-                               [[0., 0.], [0.5, 0.25], [1., 0.5]])
+                               [[0., 0.], [0.5, 0.5], [1., 1.]])
    #clusters.sort(key=mean_luma)
 
     if show_all:
    #clusters.sort(key=mean_luma)
 
     if show_all:
@@ -115,6 +115,10 @@ def stone_color_raw(image, (x, y)):
                 suma.append(image.getpixel((x + i, y + j)))
             except IndexError:
                 pass
                 suma.append(image.getpixel((x + i, y + j)))
             except IndexError:
                 pass
-    suma = (sum(s[0] for s in suma) / 25., sum(s[1] for s in suma) / 25., 
-            sum(s[2] for s in suma) / 25.)
-    return suma
+    luma = sum([0.30 * sum(s[0] for s in suma) / 25., 0.59 * sum(s[1] for s in suma) / 25., 
+            0.11 * sum(s[2] for s in suma) / 25.]) / 255.
+    saturation = sum(max(s) - min(s) / float(255. - abs(max(s) + min(s) - 255))
+                     for s in suma) / (25. * 255.)
+    color = [sum(s[0] for s in suma) / 25., sum(s[1] for s in suma) / 25.,
+             sum(s[2] for s in suma) / 25.]
+    return luma, saturation, color
similarity index 100%
rename from k_means.py
rename to imago_pack/k_means.py
similarity index 100%
rename from lhs.py
rename to imago_pack/lhs.py
similarity index 100%
rename from linef.py
rename to imago_pack/linef.py
similarity index 100%
rename from manual.py
rename to imago_pack/manual.py
similarity index 100%
rename from pso.py
rename to imago_pack/pso.py
similarity index 100%
rename from sgf.py
rename to imago_pack/sgf.py
similarity index 100%
rename from timer.py
rename to imago_pack/timer.py
index bd149a7..028e827 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,4 +1,4 @@
 install: pcf.c
 install: pcf.c
-       gcc -O3 -fPIC -shared -I/usr/include/python2.7/ pcf.c -lpython2.7 -o pcf.so
+       gcc -O3 -fPIC -shared -I/usr/include/python2.7/ pcf.c -lpython2.7 -o imago_pack/pcf.so
 clean:
        rm -f pcf.so
 clean:
        rm -f pcf.so