How to make a morph Method
I am trying to make a method in a picture class that morphs 1 photo into another, over a certain amount of frames i can choose using this formula
colorValue = startValue = ((endValue - startValue)4*k
here is what i have so far and its not working and im getting frustrated.
public void morphStage(Picture startPicture, Picture endPicture, int numStages, int k)
{
Pixel[] pixelArrayStart = startPicture.getPixels();
Pixel[] pixelArrayEnd = endPicture.getPixels();
Pixel[][][] pixelRGB = null;
Pixel pixelObjEnd = null;
Pixel pixelObjStart = null;
//***********************Colour Values for Start Photo *************************************
int redValueStart = 0;
int greenValueStart = 0;
int blueValueStart = 0;
//********************* Colour Values for End Photo ****************************************
int redValueEnd = 0;
int greenValueEnd = 0;
int blueValueEnd = 0;
//**********************Colour Values for intermediate photo********************************
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
//////////////////////////////////////////////////////////////////////////////////////////////////
for(int y = 0; y < getHeight(); )//loops colums
{
for(int x =0; x < getWidth(); )//loops rows
{
//Gets the pixel and the color of that pixel
pixelObjStart = this.getPixel(x,y);
redValueStart = pixelObjStart.getRed();
greenValueStart = pixelObjStart.getGreen();
blueValueStart = pixelObjStart.getBlue();
pixelObjEnd = this.getPixel(x,y);
redValueEnd = pixelObjEnd.getRed();
greenValueEnd = pixelObjEnd.getGreen();
blueValueEnd = pixelObjEnd.getBlue();
for(int i = 0; i < pixelArrayStart.length; )//Morhphing loop
{
pixelObjStart = pixelArrayStart[i];
redValue = redValueStart +((redValueEnd - redValueStart)/(numStages + 1))*k;
greenValue = greenValueStart +((greenValueEnd - greenValueStart)/(numStages + 1))*k;
blueValue = blueValueStart +((blueValueEnd - blueValueStart)/(numStages + 1))*k;
pixelObjStart.setRed(redValue);
pixelObjStart.setGreen(greenValue);
pixelObjStart.setBlue(blueValue);
x++;
y++;
i++;
}
}
}
}
any help would be great.
Re: How to make a morph Method
does anyone know if this actually works? , i need the method to have more than one stage in between the start and end picture...