Skip to content

Adding a Filter to Video (Actionscript)

November 17, 2009

I’ll got through making a filter and applying it to a video displaying your Webcam. In this case I tried using the ColorMatrixFilter and just turned up the saturation. On the left is the regular camera feed, on the right is the filtered camera feed.

Here’s the Actionscript:

package filterCamCode{
import flash.display.MovieClip;
import flash.filters.ColorMatrixFilter;

public class FilterCam extends MovieClip {

private var cam:Camera;
private var vid:Video;
private var vid2:Video;
private var vid3:Video;
private var cm:ColorMatrixFilter;
private var matrix:Array;

public function FilterCam() {
trace("cam width = "+cam.width);
trace("cam height = "+cam.height);
vid=new Video();

vid2=new Video();
//vid2.x= stage.stageWidth

var boost:Number = 2; //multiplys the saturation of each colour channel
var brightness:Number = -50; //offsets the final value of each colour channel
matrix= new Array(); //each row is source pixel's red, green, blue, alpha, and offset
matrix= matrix.concat([boost, 0, 0, 0, brightness]); // red
matrix= matrix.concat([0, boost, 0, 0, brightness]); // green
matrix= matrix.concat([0, 0, boost, 0, brightness]); // blue
matrix= matrix.concat([0, 0, 0, boost, brightness]); // alpha

cm= new ColorMatrixFilter(matrix);
vid2.filters = [cm];



One Comment leave one →
  1. sajil permalink
    September 18, 2011 06:34

    great post..thanks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: