Another very popular format that incorporates motion is the graphics interchange format, shortly known as gif. This is a widely used file format, which supports up to 8-bits per pixel for each color channel. It can be used for still images, but also for animation. Gif files are very frequently used in the internet due to their simplicity and portability, which allows for easy production of animations made from photographs, plots, or sketches. In MATLAB, we can make a gif file using imwrite
.
To save our time-lapse video generated in the previous example in a gif file, we have to repeat step 4, this time using imwrite
:
>> fl = 'gifTimelapse.gif'; >> for i = 1:size(v,4), [imind,cm] = rgb2ind(v(:,:,:,i),256); % Change rgb frame to indexed image if i==1, imwrite(imind,cm,fl,'gif', 'Loopcount',inf); else, imwrite(imind,cm,fl,'gif','WriteMode','append'), end end
The file we created, called gifTimelapse.gif
, can be opened using any photo editor that supports animated gif files. Its frame rate in this example is dependent on the frame rate of the original video. In general, the playback frame rate of gif files can be affected by other factors as well, for example, the browser that plays the gif.
Q1. Which of the following are true?
implay
is a tool supporting image processing tasks.struct
variable can be a matrix containing fields of different types.aviread
can read compressed videos in Unix systems.VideoReader
is the most recent video reading function in MATLAB and therefore it is the safest choice for such tasks.