Created
June 14, 2016 17:13
-
-
Save tsulej/64537b3c3f62f92a71471e968171e763 to your computer and use it in GitHub Desktop.
Simplest pixel sort for processing 2.x
This file contains hidden or 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
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