I have this code, which (I hope) locates green pixels to replace and then red pixels to replace.
public void chromakey2(Picture pictForGreen, Picture pictForRed)
{
int x;
x = 0;
while( x < this.getWidth() )
{
int y;
y = 0;
while( y < this.getHeight() )
{ Pixel pixRef = getPixel(x,y);
if( pixRef.getGreen() >
(pixRef.getBlue() + pixRef.getRed())*0.65 &&
pixRef.getBlue() > pixRef.getRed() )
{
Pixel gPixRef = pictForGreen.getPixel( x, y);
Color replacementColor = gPixRef.getColor();
pixRef.setColor( replacementColor );
}
{
if(pixRef.getRed() >
(pixRef.getBlue() + pixRef.getGreen())*0.65 &&
pixRef.getBlue()> pixRef.getGreen())
{
Pixel rPixRef = pictForRed.getPixel(x, y);
Color replacementColor = rPixRef.getColor();
pixRef.setColor(replacementColor);
}
}
y = y + 1;
}
x = x + 1;
}
}
I have another application where all I have coded is:
public class ChromakeyApp extends Picture
{
public static void main(String[]a)
{
FileChooser.pickMediaPath();
Picture pOrigRef = new Picture( FileChooser.pickAFile() );
}
}
I need to be able to let me choose the outputs of: an original picture, that original picture with the green and red pixels replaced with 2 different picture files, and the original pictures pixels replaced with another different picture file.
Any clues?