// Luminator // // by Bill Graner 1.09 // // Takes a snapshot with the video camera, then sorts pixels based on // changeable criteria (modify the function colorTest). // // Click the mouse once to take this picture and start the process. // Click again to reset. import processing.video.*; Capture myCapture; //application values final int APP_FPS = 120; final int WIDTH = 640; final int HEIGHT = 480; final int PIXELS = WIDTH * HEIGHT; //camera stuff final int CAMERA_FPS = 120; //sorting stuff final int ROWS_PER_FRAME = 500; //final int ROWS_PER_FRAME = 1; final boolean HORIZONTAL_SORT = false; final boolean VERTICAL_SORT = true; //states final int CAMERA_FEED = 0; final int TAKE_SNAPSHOT = 1; final int SORT_PIXELS = 2; final int HOLD_SNAPSHOT = 3; //FUN WITH GLOBALS ZOMG! int state = 0; int bubbleY = HEIGHT - 1; int bubbleX = WIDTH - 1; void captureEvent(Capture myCapture) { myCapture.read(); } void setup() { frameRate(APP_FPS); size(WIDTH, HEIGHT); myCapture = new Capture(this, width, height, CAMERA_FPS); state = CAMERA_FEED; } void mouseReleased() { //println("Mouse released."); switch (state) { case CAMERA_FEED: state = SORT_PIXELS; break; case HOLD_SNAPSHOT: state = SORT_PIXELS; break; case SORT_PIXELS: state = CAMERA_FEED; break; default: break; } //println("New state: " + state); } void draw() { switch (state) { case CAMERA_FEED: image(myCapture, 0, 0); break; case TAKE_SNAPSHOT: break; case SORT_PIXELS: for (int j=0; j // red(getPixel(x, bubbleY-1)) - blue(getPixel(x, bubbleY-1))) { //if (saturation(p1) > saturation(p2)) { if (colorTest(p1, p2)) { cTemp = getPixel(x, bubbleY); setPixel(x, bubbleY, getPixel(x, bubbleY-1)); setPixel(x, bubbleY-1, cTemp); } } bubbleY--; if (bubbleY <= 0) { bubbleY = HEIGHT-1; } } //HORIZONTAL SORT if (HORIZONTAL_SORT == true){ for (int y=0; y // ((brightness(c2)*1000) + saturation(c2))); // return (c1 > c2); //return (saturation(c1) < saturation(c2)); //return ( (red(c1) * green(c1) * blue(c1)) > (red(c2) * green(c2) * blue(c2))); //return (brightness(c1) > brightness(c2)); //return ((red(c1) - blue(c1)) > (red(c2) - blue(c2))); return (red(c1) > red(c2)); //return (hue(c1) > hue(c2)); // return (saturation(c1) > saturation(c2)); }