Created
January 26, 2015 08:29
-
-
Save fukuchi/874ab4b9d294136477e7 to your computer and use it in GitHub Desktop.
Noise ^ grey scaled image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.video.*; | |
Capture cam; | |
int[] noise; | |
int ticks = 0; | |
void setup() { | |
size(640, 480); | |
cam = new Capture(this, width, height, 30); | |
cam.start(); | |
noise = new int[width * height]; | |
for (int i=0; i<width * height; i++) { | |
noise[i] = (int)random(256); | |
} | |
} | |
void draw() { | |
if (cam.available() == true) { | |
cam.read(); | |
cam.loadPixels(); | |
int index = 0; | |
for (int y=0; y<height; y++) { | |
for (int x=0; x<width; x++) { | |
int v = (cam.pixels[index] >> 8) & 0xff; | |
v ^= (noise[index] + ticks) & 0xff; | |
color c = (v>128)?0xffffff:0; | |
//color c = v * 0x10101; | |
set(x, y, c); | |
index++; | |
} | |
} | |
} | |
ticks = (ticks + 1) & 0xff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment