Results 1 to 1 of 1
Thread: Testing Picture Morph Method
- 11-09-2012, 03:42 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 1
- Rep Power
- 0
Testing Picture Morph Method
Hi there! i have to create a class that tests my morph method. My method morphs one image to another in "k" steps. i was just hoping if someone could check over my method and also give me any pointers on how to create a testMorphing class that morphs one image to another using 3 steps (so startPicture -> p1 -> p2 -> p3 -> endPicture) and also how i can change if i need to do it in 9 steps?
this is my morph method:
PHP Code:public void morphStage(Picture startPicture, Picture endPicture, int numStages, int k) { Pixel[] pixelArrayStart = startPicture.getPixels(); Pixel[] pixelArrayEnd = endPicture.getPixels(); Pixel[][][] pixelRGB = null; Pixel pixelObjStart = null; Pixel pixelObjEnd = null; Pixel pixelObjNew = null; //Colour Values for Start Picture int redValueStart = 0; int greenValueStart = 0; int blueValueStart = 0; //Colour Values for End Picture int redValueEnd = 0; int greenValueEnd = 0; int blueValueEnd = 0; //Colour Values for Intermediate Picture int redValue = 0; int greenValue = 0; int blueValue = 0; for(int y = 0; y < getHeight(); ) //loops through columns { for(int x =0; x < getWidth(); ) //loops through rows { //Gets the Start pixel and the color of the pixel pixelObjStart = this.getPixel(x,y); redValueStart = pixelObjStart.getRed(); greenValueStart = pixelObjStart.getGreen(); blueValueStart = pixelObjStart.getBlue(); //Gets the End pixel and the color of the pixel 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; //set red, green, blue values to start picture pixelObjNew.setRed(redValue); pixelObjNew.setGreen(greenValue); pixelObjNew.setBlue(blueValue); x++; y++; i++; } } } }
then this is what i have so far for my testMorphing class!
**ANY KIND OF HELP IS GREATLY APPRECIATED!**PHP Code:public class TestMorphing { public static void main(String[] args) { //choose two pictures and create two picture objects String flower1 = FileChooser.pickAFile(); Picture startPicture = new Picture(flower1); int startWidth = startPicture.getWidth(); int startHeight = startPicture.getHeight(); String flower2 = FileChooser.pickAFile(); Picture endPicture = new Picture(flower2); int endWidth = endPicture.getWidth(); int endHeight = endPicture.getHeight(); if(startWidth != endWidth || startHeight != endHeight) { SimpleOutput.showInformation("Sorry, your files are not of the same size!"); } else { int rate = SimpleInput.getIntNumber("Enter Number of Stages: "); //morph picture Picture intermediate = new Picture(startWidth, startHeight); intermediate.morphStage(startPicture, endPicture, 3, 1); } } }
Thanks in advance!
Similar Threads
-
Testing a main method
By yashvi.c.shah in forum New To JavaReplies: 3Last Post: 10-21-2012, 06:26 AM -
Testing a method
By CoryBrown in forum New To JavaReplies: 5Last Post: 06-27-2012, 08:10 AM -
How to make a morph Method
By AnthonyTTaylor in forum Java 2DReplies: 6Last Post: 11-15-2011, 11:41 PM -
Getting error....picture scaleUp method
By racewithferrari in forum New To JavaReplies: 1Last Post: 11-01-2009, 04:17 PM -
Array Method Testing
By Suzanne1187 in forum Java AppletsReplies: 1Last Post: 04-15-2009, 08:23 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks