A few things.
The increment operator "++" is faster than x=x+1 or x+=1. Also, you seem to understand how to access pixels[] without understanding that to run through the whole thing, well, you just run through the whole thing. And you need to be aware of loadPixels() and updatePixels(). Select them in the code in the IDE and press Ctrl+Shft+F to look them up. You won't get very far in bitmap analysis without them.
I've cobbled together how your brief should work with some internally generated PImages.
Code:
PImage original;
PImage reference;
PImage lookup;
void setup(){
// size() ALWAYS GOES FIRST *stern wagging of finger
size(360,270);
original = randomPImage(360, 270);//loadImage("teapot.jpg");
reference = randomPImage(360, 270);//loadImage("reference.jpg");
lookup = greenPImage(360, 270);//loadImage("lookup.jpg");
noStroke();
background(255);
smooth();
}
// YOUR BRIEF:
// i want to compare the color values in original.jpg with the color values in reference.jpg.
// if it finds the same color value in reference.jpg, it should remember the position of that
// color value in reference.jpg. then gets the same position in lookup.jpg and replace the color
// value of original.jpg to the color of lookup.jpg
void draw(){
image(original, 0, 0);
}
void mousePressed(){
// This operation only needs to be performed once
for(int i = 0; i < original.pixels.length; i++){
if(original.pixels[i] == reference.pixels[i]){
original.pixels[i] = lookup.pixels[i];
}
}
original.updatePixels();
}
PImage randomPImage(int wide, int high){
PImage temp = new PImage(wide, high);
for(int i = 0; i < temp.pixels.length; i++){
temp.pixels[i] = color(random(100, 110));
}
return temp;
}
PImage greenPImage(int wide, int high){
PImage temp = new PImage(wide, high);
for(int i = 0; i < temp.pixels.length; i++){
temp.pixels[i] = color(0, 255, 0);
}
return temp;
}