manual mode -- arbitrary order of corners
[imago.git] / hough.py
index f39784b..0e9fe2d 100644 (file)
--- a/hough.py
+++ b/hough.py
@@ -30,7 +30,7 @@ class Hough:
                                     size[0] / 2)
                         # column of the matrix closest to the distance
                         column = int(round(distance)) 
                                     size[0] / 2)
                         # column of the matrix closest to the distance
                         column = int(round(distance)) 
-                        if column >= 0 and column < size[0]:
+                        if 0 <= column < size[0]:
                             matrix[column][a] += 1
 
         new_image = Image.new('L', size)
                             matrix[column][a] += 1
 
         new_image = Image.new('L', size)
@@ -46,6 +46,26 @@ class Hough:
             
         return new_image
 
             
         return new_image
 
+    def lines_from_list(self, p_list):
+        lines = []
+        for p in p_list:
+            lines.append(self.angle_distance(p))
+        return lines
+
+    def all_lines_h(self, image):
+        im_l = image.load()
+        lines1 = []
+        for x in xrange(image.size[0] / 2):
+            for y in xrange(image.size[1]):
+                if im_l[x, y]:
+                    lines1.append(self.angle_distance((x, y)))
+        lines2 = []
+        for x in xrange(image.size[0] / 2, image.size[0]):
+            for y in xrange(image.size[1]):
+                if im_l[x, y]:
+                    lines2.append(self.angle_distance((x, y)))
+        return [lines1, lines2]
+
     def all_lines(self, image):
         im_l = image.load()
         lines = []
     def all_lines(self, image):
         im_l = image.load()
         lines = []