import controlP5.*; PImage img; ControlP5 controlP5; static float imgw = 800; static float imgh = 600; PImage diffImg; static int MAXPOINTS = 10; PVector [] mypoints; float center=30.0; float width=30.0; int count=0; void setup() { size(1600, 800); img = loadImage("urs_firscher_060_push.jpg"); // Load demo image background(255); controlP5 = new ControlP5(this); controlP5.addSlider("center") .setPosition(10, imgh+20) .setRange(0, 255) .setValue(30.0) .setCaptionLabel("center"); controlP5.addSlider("width") .setPosition(10, imgh+50) .setRange(0, 255) .setValue(30.0) .setCaptionLabel("width"); mypoints = new PVector[MAXPOINTS]; diffImg = createImage((int)imgw, (int)imgh, RGB); } void draw() { createStrokeGroup(); drawStrokeGroup(); count++; if(count==10) { calcDiffImage(); count=0; } } PVector findPoint() { return findPoint(0, 255); }; PVector findPoint(float center, float width) { color c; float ix, iy; float x, y; float bright; boolean done=false; // weighted sample towards darker pixels do { ix=random(0, img.width); iy=random(0, img.height); c = img.get((int)ix, (int)iy); bright = brightness(c); if ((bright>center-width/2) && (bright<=center+width/2) && (random (width)<(float)width/2)) done=true; } while ( !done); //println(ix); //println(iy); return new PVector(ix, iy); } void createStrokeGroup() { for (int i=0;i