Computational Photography and Capture, Spring 2011

Labs

Home | Syllabus | Course Work | Assessment | Labs

Labs 1: Creation of a Pan & Scan video from an image

For this first session, you will have to deal with the Pan & Scan technique, EXIF data, and Xvid/H.264 encoding.

Pan & Scan

Pan & Scan is a technique used to create a video from a single image. It is achieved by defining a frame, which represents the boundaries of the ouput images, and sliding that frame over the original image.



We've seen it many times in cartoons, the "camera" scans horizontally a landscape, such as the image above, and the result is what you can see below.



EXIF data

Exchangeable image file format (Exif) is a specification for the image file format used by digital cameras. It contains metadata tags, such as:

  • Data and time
  • Camera settings
  • Thumbnails
  • Geolocation
  • Etc...

Encoding

Xvid is a free video codec library following the MPEG-4 standard. By using the two-pass method, we can easily create a video with a specific size (can be useful if you want to maximize the quality but have size restrictions on the output file). Videos can be encoded using VirtualDub. Here is a tutorial. Xvid is not installed on the machines of the labs, but H.264 is. You can use ffmpeg to encode a video using it. More information here.

Task

The task for this first session is to create your own video using the Pan & Scan technique. You will also have to overlay one EXIF tag from the original image onto the video (such as date and time in one corner). Finally you will have to encode your output in a video using Xvid or H.264.

This task is quite open, you can choose your own image (it must contain EXIF information), define your own camera motion, etc... Be creative. You will be using Matlab.

Guidelines:

  • Get an image containing EXIF data (it can be your own or you can download one, on Flickr for instance, or here).
  • Create a Matlab script/function that does the following:
    • Define the size of the frames, the number of frames per second and the length of the video.
    • Create a trajectory. It can be uniform, it can use a function (e.g., sin or cos), or it can follow checkpoints that you define by clicking on the image.
    • Output a certain number of images that will be the different frames of your video.
    • Overlay EXIF information on the frames.
    • Export the frames as a sequence of images.
    • Create a video from those images, using VirtualDub on windows, and ffmpeg on Linux. You can experiment with the parameters of the codecs.

Note: Matlab basic knowledge is highly recommended to be able to follow the labs. You can find a tutorial here, and more information about efficient Matlab coding here and here.

Tips:

  • Look up the command getFrame(gca) to retrieve the frame displayed in the current figure (it's more easy to overlay text on a figure than directly on an image).
  • Make sure that both height and width of the frames are even numbers, as it is required to encode a video.
  • On Windows, VirtualDub can load a sequence of images by simply opening the first image of the sequence.
  • On Linux, ffmpeg can take as input a sequence of images by using for example the following arguments: ffmpeg -i image%4d.jpg. Also, the -r flag allows you to set the number of frames per second of the output video.
  • Concerning trajectories, the getline command might be useful...