/* Image Reshuffler. Mikael Christensen 2010. This code is in the Public Domain. Use it as you like. */ PImage img; void setup() { size(700, 500); // Change to whatever picture, you'd like to use. img = loadImage("C:\\Images\\SomeImage.jpg"); img.resize(width,height); // Initial shuffle (optional) for (int i = 0;i < 1000000; i++) { int p1 = (int)random(width*height); int p2 = (int)random(width*height); color c = img.pixels[p1]; img.pixels[p1] = img.pixels[p2]; img.pixels[p2] = c; } } void draw() { img.loadPixels(); // Sort columns by hue for (int i = 0;i < 500000; i++) { int x = (int)random(width); int y = (int)random(height); int x2 = (int)random(width); int y2 = (int)random(height); x2 = x; color c = img.pixels[x + y *img.width]; color c2 = img.pixels[x2 + y2 *img.width]; if (hue(c)>hue(c2) && y>y2) { img.pixels[x + y *img.width] = c2; img.pixels[x2 + y2 *img.width] = c; } } // Sort rows by some combination of brightness and saturation for (int i = 0;i < 500000; i++) { int x = (int)random(width); int x2 = (int)random(width); int y = (int)random(height); color c = img.pixels[x + y *img.width]; color c2 = img.pixels[x2 + y *img.width]; // Try other operators, such as *,-,/ if ( saturation(c)-brightness(c)>saturation(c2)-brightness(c2) && x>x2) { img.pixels[x + y *img.width] = c2; img.pixels[x2 + y *img.width] = c; } } img.updatePixels(); // Copy to screen image(img,0,0); }