Results 1 to 3 of 3
  1. #1
    Peltoltura is offline Member
    Join Date
    Nov 2011
    Rep Power

    Exclamation How do you make a morphing method with dr java ????! URGENT, HELP PLZ

    Heyy, uhm I'm new to this forum but I have to make morphing method that morphs two picture s with a certain amount of stages in between them, but I have no idea how to ! , ease help me asap, I'm rly lost :$ :$

  2. #2
    Peltoltura is offline Member
    Join Date
    Nov 2011
    Rep Power

    Exclamation Re: How do you make a morphing method with dr java ????! URGENT, HELP PLZ

    Functional Specifications for Part A
    1. You are to write a method morphStage() for inclusion in the Picture class. It will have the header
    public void morphStage(Picture startPicture, Picture endPicture, int numStages, int
    where the parameters are:
     startPicture : the starting picture
     endPicture : the ending picture
     numStages : the total number of intermediate stages to be used in the morphing process
     k : the current stage in the morphing process (will be a number between 1 and numStages
    morphStage() will be invoked on a Picture object that is the “target” picture, that is, the picture
    that represents the kth stage in morphing from the starting picture to the ending picture. The
    method will form the picture for the current stage (ie intermediate stage k) be setting the red,
    green, and blue values for the pixels in this picture according to the above formula, pixel by
    The method may assume that the starting and ending pictures are the same size. (The
    intermediate pictures will of course be the same size as the starting and ending pictures.)
    2. You will write a class TestMorphing (in that consists primarily of a main
    method that tests morphStage() for correctness. It must contain the following tests:
    i. Get two pictures using FileChooser. If they are of the same size, form 3 intermediate
    morphed pictures and display them, along with the starting and ending pictures. (You should
    end up with a total of 5 pictures on the screen from this test: the starting picture, the 3
    intermediate morphed pictures, and the ending picture. You should be able to move them
    around on the screen using the mouse so that all can be displayed.) If the two pictures are
    not of the same size, print an error message and do not proceed with the morphing.
    ii. Get two pictures of the same size different from the ones in the first test, and perform a task
    similar to the first one, except that this time you will generate 9 intermediate morphed
    pictures. This test should result in a total of 11 pictures on the screen. Again, check that the
    pictures are of the same size first.
    You can select two of the images from the following sets of pictures that are the same size:
    {flower1.jpg, flower2.jpg}, {whiteFlower.jpg, yellowFlowers.jpg, rose.jpg}, {swan.jpg,
    twoSwans.jpg}, or you can use your own pictures that are the same size.
    Part B:
    Movies are essentially sequences of pictures that are typically displayed at 24 “frames” per
    second, each frame being a single picture. To create the effect of morphing as seen in videos and
    commercials, we would need to produce many more images and then play them in rapid succession,
    thus creating a video in which one image is morphed into the other.
    In Part B of this assignment, we will create two short “movies” of our morphed images:
     One that morphs from the starting picture to the ending picture
     Another one that morphs from the starting picture to the ending picture and then back again.
    You will make use of the FrameSequencer and MoviePlayer classes provided with our textbook in
    order to create and display a movie. The FrameSequencer class has methods that will take a
    sequence of pictures and store them in a directory; the pictures can then be displayed in rapid
    succession, thereby creating a “movie”. The MoviePlayer class has methods to play back a sequence
    of pictures already created (e.g. by FrameSequencer).
    Here is sample code to create a FrameSequencer object that will store the movie frames in the
    directory referenced by a String variable directoryName, created from an array of pictures referenced
    by a Picture[] variable pictureSequence:
    FrameSequencer frameSequencer = new FrameSequencer(directoryName);
    for (int i = 0; i < pictureSequence.length; i++)
    Once a movie has been made with FrameSequencer, we can use the MoviePlayer class to show the
    The MoviePlayer class
    A MoviePlayer object plays an existing movie. Here are the important details about this class:
     The constructor for a MoviePlayer object takes as a parameter a String that is the name of a
    directory containing the images to be displayed in the movie
     The playMovie() method opens a window in which it then displays the movie. If the
    playMovie() method is called without a parameter, it plays the movie at high speed. It can also
    accept an int parameter that specifies the number of frames to be displayed per second.
    So to play a movie, we create a MoviePlayer object and invoke the playMovie() method on it.
    Functional Specifications for Part B
    1. You will create and play your movies in a Java program with the class name MorphingMovie that
    will be saved in a file named This class will consist primarily of a main
    method whose algorithm is given below.
    2. The algorithm for the main method is:
     Get the starting picture and ending picture for the morphing, using FileChooser to get the file
    names. If the starting picture and ending picture are not the same size, print an error message
    and do not proceed with the rest of the program. (Suggestion: use the showInformation()
    method of the SimpleOutput class (see Lab 7) for your error message. )
     Input the number of intermediate stages for the morphing from the user (using the SimpleInput
     Input the name of the directory in which to store the movie. (Note that the directory name that
    the user enters should end with a slash, for example Z:/Movie1/ )
     Create an array of Picture objects that will hold the sequence of pictures for the morphing
    (Note: its length should be the number of intermediate stages + 2 )
     Store the starting and ending pictures in the array.
     Create intermediate pictures in the array, using a loop and the morphStage() method from Part
     Create the first morphing movie (which morphs from the starting picture to the ending picture)
    from the array of pictures, using a FrameSequencer object.
     Play the movie using a MoviePlayer object and playMovie().
     Now create the second morphing movie (which morphs from the starting picture to the ending
    picture and back again to the starting picture). You can do this in either of two ways:
    i. Add the “backwards” morphing sequence to the same directory ( in which case you no
    longer will be able to play your first movie)
    ii. Use a new directory for all the frames of the second movie. You would then input the
    directory name for this movie from the user.
     Play the second movie.
    3. The first movie that you make should contain at least 20 frames.
    4. For the second movie, to show the ending picture morphing back to the starting picture, do NOT do
    a reverse morphing from the ending picture to the starting picture using morphStage(). Why not?
    You already have that sequence of pictures in the array; you just want to play them backwards!
    5. Caution: If you use your own pictures, you may run out of memory space if

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: How do you make a morphing method with dr java ????! URGENT, HELP PLZ

    Private message post to me:

    Quote Originally Posted by Peltoltura
    Heyy ! :) , I'm tryong to do this assignment for class and i have no idea how to fix it so it does more stages in between the start and end picture :S , u wrote this on someone's thread :

    "Where is your data that represents p1, p2 and p3? Where you change your colour values, you'll want to have a for loop that loops on k from 1 to 3, calculates a pixel with the appropriate colors and sets the pixel into the appropriate p1 or p2 or p3 image."

    but im not shure how u'd do it :/ , this is wt i have so far... :
    Java Code:
    public void morphStage(Picture startPicture,Picture endPicture, int numStages, int k){
        Pixel[] pixelArrayStart = startPicture.getPixels(); 
        Pixel[] pixelArrayEnd   = endPicture.getPixels();
        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 i = 0; i < pixelArrayStart.length; i++){
          //Gets the pixel and the color of that pixel
          pixelObjStart   = pixelArrayStart[i];
          redValueStart   = pixelObjStart.getRed();
          greenValueStart = pixelObjStart.getGreen();
          blueValueStart  = pixelObjStart.getBlue();
          pixelObjEnd     = pixelArrayEnd[i];
          redValueEnd     = pixelObjEnd.getRed();
          greenValueEnd   = pixelObjEnd.getGreen();
          blueValueEnd    = pixelObjEnd.getBlue();
          redValue   = redValueStart +((redValueEnd - redValueStart)/
                                       (numStages + 1))*k; 
          greenValue = greenValueStart +((greenValueEnd - greenValueStart)/
                                       (numStages + 1))*k; 
          blueValue  = blueValueStart +((blueValueEnd - blueValueStart)/
                                       (numStages + 1))*k; 
    I would really apreciate help :) , its due like tmrw :S so any help would be awesome! :) thnx

Similar Threads

  1. Movie Picture Morphing
    By Mabyboi in forum Java 2D
    Replies: 1
    Last Post: 11-16-2011, 06:20 AM
  2. URGENT toString method help
    By johnnyjava in forum New To Java
    Replies: 17
    Last Post: 08-16-2011, 08:09 PM
  3. The Mystery of the auto-morphing variables
    By Luxpsycho in forum Advanced Java
    Replies: 3
    Last Post: 08-11-2011, 12:06 PM
  4. Why did Java designers make main method as static ?
    By makpandian in forum New To Java
    Replies: 9
    Last Post: 11-13-2010, 09:51 PM
  5. Morphing
    By aRTx in forum New To Java
    Replies: 4
    Last Post: 05-05-2009, 12:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts