Databending in Processing

posted by on 2013.04.02, under Processing
02:

Here’s a code in Processing that explores a simple databending technique for images. You can read about Glitch Art , and then start endelessy debate with your friends if this is art or not. :)
Also, here you can find some interesting series of videos exploring a bit also the philosophy behind databending, glitching and malfunctions as a form of awareness of the technology we are sorrounded by. (A simple example would be how the spelling mistakes in a chat messaging system make you indeed aware of the chat medium itself).
Here’s the code

PImage img;

int width=600;
int height=600;
int x1;
int y1;
int x2;
int y2;
int sx=10;
int sy=100;
int iter=100;

void setup(){
  size(width,height);

  img=loadImage("rain.jpg");
  image(img,0,0);
 
  for (int h=0;h<iter;h++)
  {
    sx=int(random(5,30));
    sy=int(random(50,130));
 
  loadPixels();
  x1=int(random(0,width-sx-1));
  y1=int(random(0,height-sy-1));
  x2=int(random(0,width-sx-1));
  y2=int(random(0,height-sy-1));
 
  for (int i=0; i<sx ;i++)
  {
    for (int j=0; j<sy;j++)
  {
    color temp=pixels[(x1+i)*width + (y1+j)];
    pixels[(x2+i)*width + (y2+j)]=pixels[(x1+int(random(0,i)))*width+(y1+int(random(0,j)))];
    pixels[(x1+i)*width + (y1+j)]=temp;
  }}
  updatePixels();
  }
};

The idea is very simple: we “swap” pixel strips of random width and height from the starting image, starting from two random points, and add some jitter to it.
We then iterate the process starting from the last modified image: the parameter iter controls the number of iterations.
Starting from this image (it’s a small piece from an image taken from the web)




I have got this


Of course, you can do a lot more interesting things by accessing directly to the pixels of an image: you can rotate areas, alter colors, etc..
And in particular, you can make animations in Processing using the same principle.
I’ll try to explores this more in future posts, trying maybe also to clear my mind about deconstructivism in art and communications…

comment

This is probably a stupid question, but how does one save the output of this? I got a window showing part of the picture but no way to save the image from what I can tell.

Phoenix ( 30/12/2014 at 2:01 pm )

Please Leave a Reply

Current ye@r *

TrackBack URL :

pagetop