Skip to content

Instantly share code, notes, and snippets.

@tsulej
Created June 14, 2016 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsulej/64537b3c3f62f92a71471e968171e763 to your computer and use it in GitHub Desktop.
Save tsulej/64537b3c3f62f92a71471e968171e763 to your computer and use it in GitHub Desktop.
Simplest pixel sort for processing 2.x
void setup() {
PImage img = loadImage("ares.jpg");
size(img.width,img.height);
image(img,0,0); // display pixels
loadPixels(); // create pixels array
int[] temp = new int[height]; // buffer for the line pixels
for(int y=0;y<height;y++) { // for each line
int pos = y*width; // where is my position in pixels
arrayCopy(pixels,pos,temp,0,width); // copy line to buffer
temp = sort(temp); // sort buffer
arrayCopy(temp,0,pixels,pos,width); // copy back to pixels
}
updatePixels(); // update pixels to screen
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment