top of page

kensukekoike filter

Single image processing has always fascinated me. It means manipulating an image without adding or removing anything from it. This makes the image into a giant puzzle playground. This program is inspired by one of my favorite artists kensukekoike


The pixel size and number of divisions can be controlled. The program also works live with face detection.









void setup() {

  size(630, 1000);
  ci=new color[width][height];
  img1=new color[width][height];
  noFill();
  
img=loadImage("save.jpg");


image(img, 0, 0);
loadPixels();
processSquare();
//splitimage();//printimage();//updatePixels();

}

PImage img;
int drawn=0;
void draw() {

  //rect(startx, starty, endx, endy);


  if( drawn==0)
  {
    image(img, 0,0);
  }
  
if(mousePressed) {
  
  if(mouseHeld==0)
  {
    mouseHeld=1;
    startx=mouseX;
    starty=mouseY;
  }
  endx=mouseX-startx;
  endy=mouseY-starty;

  //rect(startx, starty,endx , endy);
}
else
{
  mouseHeld=0;
  
}

//image(img, 0, 200);//res=int(mouseX*0.1)+1;//splitx=int(0.005*mouseY)+1;//splity=int(0.005*mouseY)+1;

  splitimage();
  printimage(); 
  updatePixels();

  
  
  
}

void mouseReleased() {
  
  drawn=1;
  //saveFrame("glitch9/image####.png");

}


color ci[][];
color img1[][];
void processSquare()
{

  for (int i = 0; i < width; ++i) {

    for (int j = 0; j < height; ++j) {

      
      ci[i][j]=pixels[j*width+i];


      
    }
    
  }
  
}

void resetimage()
{
  for (int i = 0; i < width; ++i) {

    for (int j = 0; j < height; ++j) {

      
      img1[i][j]=ci[i][j];


      
    }
    
  }

}

int splitx=2;
int splity=2;
int res=10;

void splitimage()
{


  
  for (int i = startx/(splitx); i < (int)((startx+endx)/(splitx)); i+=res) {

    for (int j = starty/(splity); j < (int)((starty+endy)/(splity)); j+=res) {

      
      
      for (int k = 0; k < splitx; ++k) {

        for (int l = 0; l < splity; ++l) {

          for (int m = 0; m < res; ++m) {

            for (int n = 0; n < res; ++n) {



              img1[int((startx+endx)/splitx)*k+i+(startx/splitx)*(splitx-k-1)+m]
                  [int((starty+endy)/splity)*l+j+(starty/splity)*(splity-l-1)+n]

                                =
              
                  ci[((i)*splitx+m)+res*k]
                    [((j)*splity+n)+res*l];
          

              
            }
            
          }



            
        }

      

        
      }

      
      
    }
    
  }
}

void printimage()
{
  for (int i = 0; i < width; ++i) {

    for (int j = 0; j < height; ++j) {

      pixels[j*width+i]=img1[i][j];
      //img1[i][j]=ci[i][j];
      
    }
    
  }
}

int mouseHeld=0;
int startx,starty, endx, endy, totalx, totaly;


Comments


bottom of page