Create extra: change background

I quickly attempted to create a function that would change the background to a file named "beach.jpg", that i put in the sketch folder. 

the program works by taking a picture (click on the webcam) where there is no person present. then click on the "Geo" button to call the function. then you will appear as if you are at the beach. 

I did this quickly, so the code is ugly. it most likely wont be put into the final copy of the project. but if any of you want to go ahead and mess with it feel free too. 

Note: 
the problem is with the lighting. I put a threshold to create a range in which colors would be considered 'equal' but it doesnt work well because the lighting throws it off a lot. 

Also if you do decide to play with it, you will need to get an image of size 1280x720, name it "beach.jpg", and put it in the same location as the .pde file.