/**EDARE blurr() method , variation on Daniel Shiffmans blur code *takes as argument x and y of image, name of image, width and height you would like it to be * */ PImage a, img2; //you dont have to worry about anything but caling the method //called blurr() //supplying these arguments: //x and y of image, name of image, width and height of image as you would like it drawn void setup(){ size(500, 500); background(255); a = loadImage("trees.jpg"); // Load the images into the program img2 = loadImage("face.jpg"); } void draw(){ // Load the pixels for each image: img2.loadPixels(); a.loadPixels(); image(a, 10, 10, 80, 80); //smallest image image(img2, 100, 100, 120, 120); //second image image(a,250, 250, 200, 200); //biggest image image(img2, 10, 370, 120, 120); //bottom left this will never be affected int aa = millis()/1000; //our simple but efective timer //do some conditional blurs: if((aa > 5) &&( aa<12)) { //after 5 seconds do this, stop at 12 seconds //call blurr() method x and y of image, name of image, width and height: blurr(10, 10, a, 80, 80); //blur smallest } if((aa > 12) &&( aa<26)) { //after 12 seconds do this, stop at 25 seconds //call blurr() method x and y of image, name of image, width and height: blurr(100, 100, img2, 120, 120); //blur middle image } if((aa > 27) &&( aa<37)) { //call blurr() method x and y of image, name of image, width and height: blurr(250, 250, a, 200, 200); //blur biggest } } ///////////////////SUPER IMPRTOVED BLURR METHOD TAKES WHATEVER IMAGE WE NAME AND //BLURS IT, adapt the convolution kernel for other fab effects! //x and y of image, name of image, width and height: void blurr(int xp, int yp, PImage img, int size1, int size2){ float v = 1.0/9.0; float[][] kernel = { { v, v, v } , { v, v, v } , { v, v, v } }; PImage edgeImg = createImage(img.width, img.height, RGB); // Loop through every pixel in the image. for (int y = 1; y < img.height-1; y++) { // Skip top and bottom edges for (int x = 1; x < img.width-1; x++) { // Skip left and right edges //here I make it work with colour images: float sum = 0; // Kernel sum for this pixel float sum2 = 0; // Kernel sum for this pixel float sum3 = 0; // Kernel sum for this pixel for (int ky = -1; ky <= 1; ky++) { for (int kx = -1; kx <= 1; kx++) { // Calculate the adjacent pixel for this kernel point int pos = (y + ky)*img.width + (x + kx); // Image is grayscale, red/green/blue are identical float val = red(img.pixels[pos]); float val2 = green(img.pixels[pos]); float val3 = blue(img.pixels[pos]); // Multiply adjacent pixels based on the kernel values sum += kernel[ky+1][kx+1] * val; sum2 += kernel[ky+1][kx+1] * val2; sum3 += kernel[ky+1][kx+1] * val3; } } // For this pixel in the new image, set the gray value // based on the sum from the kernel edgeImg.pixels[y*img.width + x] = color(sum, sum2, sum3); } } // State that there are changes to edgeImg.pixels[] edgeImg.updatePixels(); image(edgeImg, xp, yp, size1, size2); // Draw the new image } ///end of blurr() methodddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd