Variable Declaration, aka Iterative Sanity →← Thoughts on Pixel Bender

Custom filters (sort of) without Pixel Blender

Following up on Andrews post concerning Pixel Bender I’ve recently been playing with the convolution filter and I thought I’d share some findings. The convolution filter allows you to pass a matrix of values that are iterated over the pixels of a source image that influence the pixels in the original image. This is more or less what an image filter in pixel bender is doing.


When you make a new document in pixel bender right at the top you will see the syntax: kernel myFilter The matrix property in a convolution matrix is essentially a kernel, that is, an array of numbers telling the image how to be manipulated. For example a simple blur kernel might be represented like this:
var c:ConvolutionFilter = new ConvolutionFilter();
c.matrixX = 3;
c.matrixY = 3;
c.matrix = [1,1,1,
1,1,1,
1,1,1];
c.divisor = 9;
This is telling the filter to take the values of all of the surrounding pixels, and average them which results in a slight blur.

Another I’ve found useful is a simple Laplacian kernel used in LoG (Laplacian of Gaussian) which is useful for finding edges and blob detection.
var c:ConvolutionFilter = new ConvolutionFilter();
c.matrixX = 3;
c.matrixY = 3;
c.matrix = [0,-1,0,
-1,4,-1,
0,-1,0];
c.divisor = 1;

While this is certainly less robust than pixel bender it’s a good place to start playing around to help you understand what is going on behind the scenes.

September 12th, 2008  by Charlie  /  0 Comments
actionscript, flash


Comments on “Custom filters (sort of) without Pixel Blender”