small changes
authorTomas Musil <tomik.musil@gmail.com>
Fri, 6 Apr 2012 13:46:41 +0000 (15:46 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Fri, 6 Apr 2012 13:46:41 +0000 (15:46 +0200)
commons.py [new file with mode: 0644]
filter.py
hough.py

diff --git a/commons.py b/commons.py
new file mode 100644 (file)
index 0000000..787a19d
--- /dev/null
@@ -0,0 +1,7 @@
+import os
+
+def clear():
+    if os.name == 'posix':
+        os.system('clear')
+    elif os.name == ('ce', 'nt', 'dos'):
+        os.system('cls')
index 7421fea..c350ef5 100644 (file)
--- a/filter.py
+++ b/filter.py
@@ -1,9 +1,12 @@
 from PIL import Image
+from commons import clear
 
 def edge_detection(image):
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
+    clear()
+    print "edge detection"
     for x in range(2, image.size[0] - 2):
         for y in range(2, image.size[1] - 2):
             pix = sum([sum([image_l[a, b] for b in range(y - 2, y + 3)]) for a in range(x - 2, x + 3)]) - (25 * image_l[x, y])
@@ -18,8 +21,10 @@ def high_pass(image, high_pass):
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
-    for x in range(image.size[0]):
-        for y in range(image.size[1]):
+    clear()
+    print "high pass filter"
+    for x in xrange(image.size[0]):
+        for y in xrange(image.size[1]):
             if image_l[x, y] < high_pass:
                 new_image_l[x, y] = 0
             else:
index 22c52f3..7ac3aac 100644 (file)
--- a/hough.py
+++ b/hough.py
@@ -1,12 +1,6 @@
 from PIL import Image
 from math import sin, cos, pi
-import os
-
-def clear():
-    if os.name == 'posix':
-        os.system('clear')
-    elif os.name == ('ce', 'nt', 'dos'):
-        os.system('cls')
+from commons import clear
 
 def transform(image):
 
@@ -20,7 +14,7 @@ def transform(image):
 
     for x in xrange(size[0]):
         clear()
-        print "{0}/{1}".format(x + 1, size[0])
+        print "hough transform: {0}/{1}".format(x + 1, size[0])
         for y in xrange(size[1]):
             if image_l[x, y]:
                 # for every angle: