PImage img;

void setup(){
  img = loadImage("IMG_9103.JPG");
  size(500,500);
}

void draw() {
  if(mousePressed) {
    // replace this chunk with a function
    // draw image in grayscale
    loadPixels();
    img.loadPixels();
    for(int i = 0; i < pixels.length; i++) {
      pixels[i] = color(brightness(img.pixels[i]));
    }
    img.updatePixels();
    updatePixels();
  }
  else {
    // draw image in color
    image(img,0,0);
  }
}