Recurrent Expressions – Outtakes #2 [pixel_sorting]

I’m such a fool for pixel sorting. 

Later on I used the same sketch for messing up a picture of my friend Dr. Distorto.

Outtakes from the self-published digital art-zine Recurrent Expressions.

  
PImage img;
int sort = 100;

void setup() {
 //Size should match your image width and height.
  size(800, 800);
  img = loadImage("myImage.jpg");
}

void draw() {

  loadPixels();
  img.loadPixels();
  color tempPixel = 0;

  for (int y = 1; y < height; y++) {
    for (int x = 1; x < width; x++) {

      int loc = x + y*width;

      for (int pos = 1; pos < sort; pos++) {
          
          if (brightness(img.pixels[loc]) > 100) { 
            
           //Diferent glitchy effects:
            
          //Difuminating:
          tempPixel = img.pixels[loc - (int) random(pos)]; 
          
          //Double vision fx:
          //tempPixel = img.pixels[loc - pos]; 
          
          //Water noise like:
          //tempPixel = img.pixels[loc - 
          //(int) (sort * noise(x * 0.09, y * 0.01))]; 
          
          //Paint scratching:
          //tempPixel = img.pixels[loc - 
          //(int) (pos * noise(x * 0.09, y * 0.01))]; 
        }
        pixels[loc] = tempPixel;
      }
    }
  }

  updatePixels();

  //save("sorting_" + sort + ".jpg");

  noLoop();
}  

Leave a Comment

Your email address will not be published. Required fields are marked *