binary image for camera by perlin noise
@author
import processing.video.*;
Capture camera;
PVector offset;
float scale = 0.01;
float tScale = 0.1;
color c1 = color(255, 20, 147);
color c2 = color(255, 140, 0);
float threshold = 127;
void setup(){
size(640, 480);
noStroke();
offset = new PVector(random(10000), random(10000));
camera = new Capture(this, 320, 240);
camera.start();
}
void draw(){
background(0);
camera.loadPixels();
for(int x = 0; x < camera.width; x += 1){
for(int y = 0; y < camera.height; y += 1){
color c = camera.pixels[y * camera.width + x];
float grey = 0.30 * red(c) + 0.59 * green(c) + 0.11 * blue(c);
if(grey < threshold){
float cr = map(noise(x * scale + offset.x, y * scale + offset.y, frameCount * tScale), 0, 1, red(c1), red(c2));
float cg = map(noise(x * scale + offset.x, y * scale + offset.y, frameCount * tScale), 0, 1, green(c1), green(c2));
float cb = map(noise(x * scale + offset.x, y * scale + offset.y, frameCount * tScale), 0, 1, blue(c1), blue(c2));
fill(cr, cg, cb);
rect(x * 2, y * 2, 2, 2);
} else {
fill(map(noise(x * 0.001 + offset.x, y * 0.01 + offset.y, frameCount * 0.03), 0, 1, 255, 160));
rect(x * 2, y * 2, 2, 2);
}
}
}
}
void captureEvent(Capture camera){
camera.read();
}