5. Cube Spin
Cube Spin strech image A and image B to obtain a cube spin like transition. In order to strech the image, we use the function iplWarpPerspective, which take as the argument the source image, destination image, Quadrangle of new image, warpflag, and type of interpolation.
Quadrangle for image A (x1,y1;x2,y2;x3,y3;x4,y4) starts from 0,0, and goes to width 1, along with the time.
Quadrangle for image B starts from 0,0, and goes along with A to 1.
Notes: If we need to change the value of x1,y1,x2,y2,x3,y3,x4,y4, don't forget to set it back to the array of quadrangle, otherwise the value of the quadrangle will never get set.
This is what it looks like when image B and image A strected together in image R.
Here is when image B is streched almost completely over image A, creating a cube spin
like movement.
6. Rotate
This transition rotate image A until time 0.5(image A rotate for 90 degrees), and put image B afterwards. Finally, rotate image B again until initial position.
In order to do this, we will need to use warp Perspective, and define the quadrangle outside the image. As time goes, image R rotate 90 degrees toward the back of the image, so we will need to decrement y1 and y4, and increment y2 and y3. The x goes to the right as usual. When the time reach 0.5, Image B is loaded, and we want to increment y1 and y4, and decrement y2 and y3 in order to get back to the first position.
Here image A is rotated toward the back of image R.
At the second half, image B is inserted to the image R. Notice that we need to set image R to 0 for every different time, so the previous result doesn't shows up in the new image.
Result1 |