comments for pso
[imago.git] / imago_pack / filters.py
index 3a64039..50a9a01 100644 (file)
@@ -1,8 +1,15 @@
+"""Image filters module.
+
+All filters return a filtered copy of the image, the original image is
+preserved.
+"""
+
 from PIL import Image, ImageFilter
 
 import pcf
 
 def color_enhance(image):
 from PIL import Image, ImageFilter
 
 import pcf
 
 def color_enhance(image):
+    """Stretch all color channels to their full range."""
     image_l = image.load()
     min_r, min_g, min_b = 999, 999, 999
     max_r, max_g, max_b = -1, -1, -1
     image_l = image.load()
     min_r, min_g, min_b = 999, 999, 999
     max_r, max_g, max_b = -1, -1, -1
@@ -30,6 +37,7 @@ def color_enhance(image):
     return new_image
 
 def edge_detection(image):
     return new_image
 
 def edge_detection(image):
+    """Edge detection (on BW images)."""
     new_image = image.filter(ImageFilter.GaussianBlur())
     # GaussianBlur is undocumented class, it might not work in future versions
     # of PIL
     new_image = image.filter(ImageFilter.GaussianBlur())
     # GaussianBlur is undocumented class, it might not work in future versions
     # of PIL
@@ -38,6 +46,7 @@ def edge_detection(image):
     return new_image
 
 def peaks(image):
     return new_image
 
 def peaks(image):
+    """Peak filter (on BW images)."""
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
@@ -57,6 +66,7 @@ def peaks(image):
     return new_image
 
 def high_pass(image, height):
     return new_image
 
 def high_pass(image, height):
+    """High pass filter (on BW images)."""
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
     image_l = image.load()
     new_image = Image.new('L', image.size)
     new_image_l = new_image.load()
@@ -70,6 +80,8 @@ def high_pass(image, height):
 
     return new_image
 
 
     return new_image
 
+# TODO factor these into one method
+# TODO comment it
 def components(image):
     image_l = image.load()
     new_image = Image.new('L', image.size)
 def components(image):
     image_l = image.load()
     new_image = Image.new('L', image.size)
@@ -119,7 +131,6 @@ def components(image):
                 c += 1
             new_image_l[int(round(float(x_c)/c)), int(round(float(y_c)/c))] = 255
 
                 c += 1
             new_image_l[int(round(float(x_c)/c)), int(round(float(y_c)/c))] = 255
 
-
     return new_image
 
 def components2(image):
     return new_image
 
 def components2(image):