Skip to content

Instantly share code, notes, and snippets.

@bgola bgola/disorder.pde
Created Sep 6, 2016

Embed
What would you like to do?
import java.util.Map;
PImage img;
int sf=0;
float frame = 0;
void setup() {
size(851, 315);
img = loadImage("path");
img.resize(width, height);
}
void draw() {
background(0);
loadPixels();
float[] columns = new float[width];
float[] columns_sorted = new float[width];
HashMap<Float,Integer> hm = new HashMap<Float,Integer>();
float n = 0;
for(int i=0; i<width; i++) {
float total=0;
for (int j=0; j<height; j++) {
color c = img.get(i, j);
total += brightness(c);
}
float mean = total / height;
columns[i] = mean;
hm.put(mean, i);
}
columns_sorted = sort(columns);
for (int c=0; c<width; c++) {
int column = hm.get(columns_sorted[width-c-1]);
for (int l=0; l<height; l++) {
n+=0;
int pixel = (int)(width*l+c) ;// + (map(noise(n), 0, 1, -10, 10)));
if (pixel < 0) pixel = 0;
if (pixel > (width-1)*(height-1)) pixel = (width-1)*(height-1);
//pixels[pixel] = color(brightness(img.get(line, x)));
pixels[pixel] = img.get(column, l);
}
}
updatePixels();
}
void keyPressed() {
if (key == 's') {
save("frame.jpg");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.