I'm having problems with this assignment I have to do for my java programming class. What I have to do is perform a chroma key technique on an image with a solid background. More info can be found here. The method I created works when I put the two object parameters for the method. But, when I put the parameters in the constructor and then try to use the method, I get a compiler error. I have my class down below (I have to use two different classes, one for methods, one for testing). Any help would be appreciated, I'm new to java and the most simple route would be best.
public class ChromaKey
{
public ChromaKey(Picture backgroundDelete, Picture backgroundImage)
{
}
public void chromaKey()
{
int redValue = 0; int greenValue = 0; int blueValue = 0;
Color pixelColor = null;
Color pixelColor1 = null;
for(int y = 0; y < backgroundImage.getHeight(); y++)
{
for(int x = 0; x < backgroundImage.getWidth(); x++)
{
Pixel targetPixel = new Pixel(backgroundImage,x,y);
Pixel targetPixel1 = new Pixel(backgroundDelete,x,y);
targetPixel = backgroundImage.getPixel(x,y);
pixelColor = targetPixel.getColor();
targetPixel1 = backgroundDelete.getPixel(x,y);
pixelColor1 = targetPixel1.getColor();
int targetRed = pixelColor1.getRed();
int targetBlue = pixelColor1.getGreen();
int targetGreen = pixelColor1.getBlue();
int backgroundRed = pixelColor.getRed();
int backgroundGreen = pixelColor.getGreen();
int backgroundBlue = pixelColor.getBlue();
if(targetRed >= 200 && targetBlue >= 200 && targetGreen >= 200)
{
targetPixel1.setRed(backgroundRed);
targetPixel1.setGreen(backgroundGreen);
targetPixel1.setBlue(backgroundBlue);
}
}
}
backgroundImage.show();
backgroundDelete.show();
}
}