If you are using Processing this could be useful.
Use Processing to scan an image pixel by pixel, so they could be compare to find pattern's in the image.
PImage sample;
void setup() {
size(300,300);
sample = loadImage("sample.jpg");
sample.loadPixels();
image(sample,0,0,300,300);
}
void draw() {
//Loop to scan the image pixel by pixel
for (int x=0; x < sample.width; x++){
for (int y=0; y < sample.height; y++){
int location = x + (y * sample.width);
// Whit the location you can get the current color
color currentColor = sample.pixels[loc];
//Do something
}
}
}