/** *

A little demo to showcase the ERODE and DILATE filters in action. *

* These filters can come in handy for computer vision tasks (e.g. noise removal or as part of an image/feature segmentation process). * In general there are other possible kernel shapes for this type of filter, though the diamond shaped one (as used here) performs faster. *

*/ PImage cam; boolean isEroding=true; void setup() { size(320,240,P3D); cam=loadImage("infrared2.jpg"); } void draw() { image(cam,0,0); } void mousePressed() { cam.filter(isEroding ? ERODE : DILATE); } void keyPressed() { if ((key&0x5f)=='L') cam=loadImage("infrared2.jpg"); if (key==' ') isEroding=!isEroding; }