/* Some starter code for the green screen algorithm */ //Get the green screen image var greenScreen = new SimpleImage("drewRobert.png"); //Get a background image var background = new SimpleImage("dinos.png"); //Use the green screen image to make a new image that combines green screen and background var greenWidth = greenScreen.getWidth(); var greenHeight = greenScreen.getWidth(); //Finsh this var finalImage = new SimpleImage(greenWidth, greenHeight);//Add Values); //Set a green pixel tolerance--change and see results var greenTolerance = 200; function makeGreenScreen() { //Loop through all the pixels of greenScreen for(var pixel of greenScreen.values()) { //Get the coordinates of current pixel var x = pixel.getX(); var y = pixel.getY();//You finish //Determine if green pixel is above tolerance if(pixel.getGreen() > 200) { var backgroundPix = background.getPixel(x, y); finalImage.setPixel(x, y, backgroundPix); } else { //Set it to the green screen pixel finalImage.setPixel(x, y, pixel) } } //Change the 3 to whatever will make the image fit your screen finalImage.setSize(greenWidth/3, greenHeight/3); print(finalImage); } //Call the above function makeGreenScreen()