Using a single JPEG image, we can create image sequences. To create image sequences, we need to convert the image into frame. The matlab function ‘im2frame’ is used to create frame from an image. In this example, I took an image and created some frames by performing rotation operation on that image.
Initially, I pre allocated a structure array. When the function ‘im2frame’ is used on an image, a frame is created. The frame is a structure that contains the cdata and the colormap.
cdata: [323x400x3 uint8]
After allocating the space for the frames, I rotated the image from 1 to 360 degrees with the interval of 10 degrees. 36 frames will be obtained.
During each rotation operation, the size of the image will be modified. So, I resized the image to the original size after every rotation.
%Create a video from still image
%Preallocate the structure array
%The fields are 'cdata' and 'colormap'
%The size should be 1xm
%Rotate the image
%To convert an image to frame use the function 'im2frame'.
%set(scz, 'position', [300 100 size(I,1)+200 size(I,2)]);
%Play the image sequence with fps=10.
We can either use ‘movie’ function or ‘implay’ function to play the video.
If the ‘movie’ function is used. Then we can specify the window size and the position.
N-number of times
FPS-Frames per second
Function : implay
It can take two parameters, frames and the FPS.