This was an exercise in convolution filtering I wrote in Python for AI class. Here's a very brief summary of convolution filtering:

Convolution filtering is nothing more than a two dimensional mathematical convolution. For every pixel in the image, a matrix, called a kernel, is applied as follows:

 Given a kernel:
      k0  k1  k2
      k3  k4  k5 
      k6  k7  k8

 And a pixel matrix of equal size:
      p0  p1  p2
      p3  p4  p5
      p6  p7  p8

    \forall p4 \in Image: p4 = \sum_{i=0}^{8}k_i*p_i

There are a number of standard image convolution kernels, such as:

  Edge detection:
       1.0  2.0  1.0
       0.0  0.0  0.0
      -1.0 -2.0 -1.0

       2.0  0.0  0.0
       0.0 -1.0  0.0
       0.0  0.0 -1.0

The kernel can be of any size; I use 3x3 kernels in RGB Convolution. As this is generally the first step in a longer process, the images are often converted to greyscale, which means the convolution needs only be calculated on a single channel. As my goal was more or less to write a nifty program, I opted for the more time consuming process of applying a separately customized kernel to each color channel.

The program consists of a file called, with a single function that takes a Python Imaging Library Image object and an array of the RGB kernels, and it returns a new modified Image object after convolution has been performed. There is also file called, which is a rough Tkinter GUI for the program.

I've also included two example images.

You can find RGB Convolution here: Download Documentation