makefile, readme
[imago.git] / filters.py
index 825834f..c53b6e8 100644 (file)
@@ -1,26 +1,13 @@
 from PIL import Image, ImageFilter
 
 from PIL import Image, ImageFilter
 
+import pcf
+
 def edge_detection(image):
     image = image.filter(ImageFilter.GaussianBlur())
     # GaussianBlur is undocumented class, it might not work in future versions
     # of PIL
 def edge_detection(image):
     image = image.filter(ImageFilter.GaussianBlur())
     # GaussianBlur is undocumented class, it might not work in future versions
     # of PIL
-    image_l = image.load()
-    new_image = Image.new('L', image.size)
-    new_image_l = new_image.load()
-    
-    for x in xrange(2, image.size[0] - 2):
-        for y in xrange(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]))
-            if pix > 255:
-                pix = 255
-            if pix < 0:
-                pix = 0 
-            new_image_l[x, y] = pix
-    return new_image
+    image = Image.fromstring('L', image.size, pcf.edge(image.size, image.tostring()))
+    return image
 
 def peaks(image):
     image_l = image.load()
 
 def peaks(image):
     image_l = image.load()
@@ -33,7 +20,7 @@ def peaks(image):
                 - image_l[a, b] 
                     for b in range(y - 2, y + 3)]) 
                     for a in range(x - 2, x + 3)])
                 - image_l[a, b] 
                     for b in range(y - 2, y + 3)]) 
                     for a in range(x - 2, x + 3)])
-                + (16 * image_l[x, y]))
+                + (17 * image_l[x, y]))
             if pix > 255:
                 pix = 255
             if pix < 0:
             if pix > 255:
                 pix = 255
             if pix < 0: