Thursday 5 March 2009

Exploring the Filter Method

The Filter method can apply 7 different modes to an image which has been loaded into the display area.
filter(THRESHOLD);
filter(GRAY);
filter(INVERT);
filter(POSTERIZE);
filter(BLUR);
filter(OPAQUE);
filter(ERODE);
filter(DILATE);
The method has two different forms. The first as seen above just accepts the mode constant, as a parameter. The second accepts MODE and a number as an integer or float which represents the magnitude of the filter on the image.

ThresholdMode

Top-Left image has had a threshold filter of 0.1 applied.

Top-Right image has had a threshold filter of 0.5 applied.

Bottom-Left image has had a threshold filter of 0.9 applied.

Bottom-Right image has been added to the sketch folder and displayed on the screen.







Code to produce above image in Processing
int sizeWindow=700;
int fCount=0;
PImage a,b,c,d;
String fName="c28.jpg";
void setup(){
size(sizeWindow, sizeWindow);
a=loadImage(fName);
b=loadImage(fName);
c=loadImage(fName);
d=loadImage(fName);
//smooth();
//frameRate(.5);
noLoop();
}
void draw(){
image(a,0,0,width/2,height/2);

//b=get(0,0,width/2,height/2);
filter(THRESHOLD,.1);
image(b,width/2,0,width/2,height/2);

filter(THRESHOLD,.5);
image(c,0,height/2,width/2,height/2);

filter(THRESHOLD,.9);
image(c,width/2,height/2,width/2,height/2);
}
An image must be added to the sketch and renamed 'c28.jpg' or the code can be edited with the name of another image.

No comments:

Post a Comment