+"""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):
+ """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
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
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()
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()
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)
c += 1
new_image_l[int(round(float(x_c)/c)), int(round(float(y_c)/c))] = 255
-
return new_image
def components2(image):