Monday 21 May 2007

Computer Graphics Lab 1 : Morph

Ok, this is another assignment from my computer graphics module. The first one in fact. We were to put in the code which could morph pictures.



How does it work? Well, first you got to watch the video once. Then notice the red lines near the end of the video? Those are the guides to the morph. What the program tries to do is move each red line in the source picture (cat) closer towards the corresponding red line in the alternate picture (dog). As it is moving the lines, it calculates the pixels which need to be stretched or changed during that frame according to a mathematical formula. Well, actually its abit more complicated than that but that's the gist.

For the video above, I am actually trying to show you the different modes of the program. What I did not show was the long computation time it took to calculate 24 frames for that second. It took about 3 to 4 seconds to compute each frame. So nope, morphing using this algorithm is not real-time! As for the modes, I first showed the source and target blended morph, then the source-only morph (cat), then the target-only morph (dog), then blended with the guides. Blended meaning an interpolation of transparency. So the cat is 0% transparent and the dog 100% on the first frame. The cat 50% and the dog 50% on the middle frame. The cat 100% and the dog 0% on the last frame.

I did not really find the assignment hard since we were given an algorithm to follow but I did learn alot from this assignment and was really amazed at how maths could be used to manipulate so many things. It was also only in this module that I realised Adobe Photoshop was all about powerful maths. Yup all your strange effects and tools are all essentially some kind of formula. Some are really complicated and thus the slow computation times and some are really straightforward and fast. Oh and I would also like to state that I did not do all the programming. Most of the framework was provided by the lecturer and we only had to fill up the morphing algorithm.

well that's all for today! (lucky i found out how to do the video stuff yesterday so this post only took a short time) Oh but i did find out more about the flv player today. A surprising fact that it can actually have a different frame rate from the swf it is contained in so that videos of different frame rates will all be played at its correct frame rate. This is unlike the rule where a swf contained in another swf will follow the frame rate of the parent swf. Also, the flvplayer can resize itself to fit the video it is play. This is a really wonderful feature because that means I can use one player for all my flv videos of different sizes and frame rates. Awesome.

More computer graphics stuff for the rest of this week! I have decided to make this week Academic-related Posts week.

1 comment:

Anonymous said...

Keep up the good work.

Get Adsense

Want to earn money like me? Get Google Adsense now by clicking this