vendredi 3 novembre 2017

Understanding Chromakey

Given this sample code that replaces all the blue with a new background:

public void chromakeyBlue(Picture newBg)
{
    Pixel [] pixelArray = this.getPixels();
    Pixel currPixel = null; 
    Pixel newPixel = null;

    for (int i = 0; i < pixelArray . length ; i++) { 
        currPixel = pixelArray [ i ];

        if (currPixel.getRed() + currPixel.getGreen() < currPixel . getBlue ())
        { 
            newPixel = newBg.getPixel(currPixel.getX(), 
                                      currPixel.getY ( ) ) ;
            currPixel . setColor ( newPixel . getColor ( ) ) ;
        } 
    }
}

I was wondering if using this condition :

currPixel.getRed() < currPixel.getBlue() && currPixel.getGreen() < 
currPixel.getBlue()

on the if statement, if it would work or not. In other words, does using that condition have the same affect as currPixel.getRed() + currPixel.getGreen() < currPixel . getBlue ()?

Aucun commentaire:

Enregistrer un commentaire