Chapter 7. Adding Motion – From Static Images to Digital Videos

In all the previous chapters, we have focused on ways to import, manipulate, process, and save static images using MATLAB, in numerous manners and for various goals. Now, it is time to slowly indulge in the peculiarities of video processing, using MATLAB as our only tool. We will start with explaining the nature of videos and the ways they can be created. Some necessary theoretical details about videos will be explained, followed by instructions on how to load and view videos in MATLAB. Then, we will continue with ways to create video streams using static images. These are the fundamentals of time-lapse videos, so by the end of this chapter you will be able to make your first time-lapse video using MATLAB. Finally, we will provide another way to save your time-lapse sequence, which is in gif format.

In this chapter, we will learn:

  • The basic principles of digital video processing
  • The significance of frame rates
  • How we can load videos in MATLAB
  • How we can playback videos in MATLAB
  • How we can create videos using static images
  • How we can inspect all or some of the frames in a video, using MATLAB
  • How to use implay to playback a video
  • How we can create and save time-lapse videos in MATLAB

So, let's start working with videos!

An introduction to digital videos

To build a solid foundation for this chapter, as well as the next ones, we must first take some time to present the fundamental concepts of digital videos. Once again, the theory will be explained in a very practical way, using hands-on examples wherever possible.

Videos are practically created by joining several still images, called frames. The joining of the images is performed by adding an extra dimension to hold the sequence. Since, as you already know by now, grayscale images are two-dimensional and color images are three-dimensional, grayscale videos will be three-dimensional and color videos will be four-dimensional. For example, if we join 100 grayscale images of size 1080 rows and 1920 columns, we will get a matrix that is 1080 x 1920 x 100. Similarly, if we join 100 color images of the same size, the resulting matrix will be 1080 x 1920 x 3 x 100.

The most usual and natural way to create a digital video is to use a video capturing device, for example, a video camera. Modern photographic cameras also have the capability of shooting digital video. Moreover, since a video can be thought of as a sequence of consecutive still images, it can also be created using photographs, or even sketches. This is a technique that can also be used to create animated .gif files, as we will see in this chapter. But first, we should try to explain some important aspects of video processing, always bearing in mind that all the descriptions pertain to uncompressed videos.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset