BImage a; void setup() { size(250,333); a = loadImage("house1.gif"); } void loop() { background(266); //we're only going to process a portion of the image so let's set the whole image as the background first image(a,40,40,160,240); //For drawing a black rectangle defining area for processing stroke(0); noFill(); rectMode (CENTER_DIAMETER); //drawing sensor lines line(mouseX,mouseY+50,440-mouseX,mouseY); line(mouseX,mouseY+50,400-mouseX,mouseY); line(mouseX,mouseY+50,355-mouseX,mouseY); line(mouseX,mouseY+50,325-mouseX,mouseY); line(mouseX,mouseY+50,300-mouseX,mouseY); line(mouseX,mouseY+50,255-mouseX,mouseY); line(mouseX,mouseY+50,235-mouseX,mouseY); line(mouseX,mouseY+50,200-mouseX,mouseY); line(mouseX,mouseY+50,150-mouseX,mouseY); line(mouseX,mouseY+50,100-mouseX,mouseY); line(mouseX,mouseY+50,50-mouseX,mouseY); line(mouseX,mouseY+50,35-mouseX,mouseY); line(mouseX,mouseY+50,25-mouseX,mouseY); line(mouseX,mouseY+50,15-mouseX,mouseY); line(mouseX,mouseY+50,10-mouseX-100,mouseY); line(mouseX,mouseY+50,5-mouseX-50,mouseY); //what are the boundaries for the pixels we are processing int X1 = constrain(mouseX-40,0,a.width); int Y1 = constrain(mouseY-40,0,a.height); int X2 = constrain(mouseX+40,0,a.width); int Y2 = constrain(mouseY+40,0,a.height); //begin our loop for every pixel for (int x = X1; x < X2; x++) { for (int y = Y1; y < Y2; y++ ) { //calculate the 1D location from a 2D grid int loc = x + y*a.width; //get the R,G,B values from image float r,g,b; r = red (a.pixels[loc]); g = green (a.pixels[loc]); b = blue (a.pixels[loc]); //make a new color and set pixel in the window color c = color(0,g,b); pixels[loc] = c;//a.pixels[loc]; } } }