Image Processing Toolbox    

Displaying Multiframe Images

A multiframe image is an image file that contains more than one image. The MATLAB-supported formats that enable the reading and writing of multiframe images are HDF and TIFF. See Multiframe Image Arrays for more information about reading and writing multiframe images.

Once read into MATLAB, the image frames of a multiframe image are always handled in the fourth dimension. Multiframe images can be loaded from disk using a special syntax of imread, or created using MATLAB. Multiframe images can be displayed in several different ways; to display a multiframe image, you can

Displaying the Frames of a Multiframe Image Individually

In MATLAB, the frames of a multiframe image are handled in the fourth dimension. To view an individual frame, call imshow and specify the frame using standard MATLAB indexing notation. For example, to view the seventh frame in the intensity array I,

The following example loads mri.tif and displays the third frame.

Intensity, indexed, and binary multiframe images have a dimension of m-by-n-by-1-by-k, where k represents the total number of frames, and 1 signifies that the image data has just one color plane. Therefore, the following call,

is equivalent to,

RGB multiframe images have a dimension of m-by-n-by-3-by-k, where k represents the total number of frames, and 3 signifies the existence of the three color planes used in RGB images. This example,

shows all three color planes of the seventh frame, and is not equivalent to

which shows only the third color plane (blue) of the seventh frame. These two calls will only yield the same results if the image is RGB grayscale (R=G=B).

Displaying All Frames of a Multiframe Image at Once

To view all of the frames in a multiframe array at one time, use the montage function. montage divides a figure into multiple display regions and displays each image in a separate region.

The syntax for montage is similar to the imshow syntax. To display a multiframe intensity image, the syntax is

To display a multiframe indexed image, the syntax is

This example loads and displays all frames of a multiframe indexed image.

Figure 3-1: All Frames of Multiframe Image Displayed in One Figure

Notice that montage displays images in a row-wise manner. The first frame appears in the first position of the first row, the next frame in the second position of the first row, and so on. montage arranges the frames so that they roughly form a square.

Converting a Multiframe Image to a Movie

To create a MATLAB movie from a multiframe image array, use the immovie function.

This call creates a movie from a multiframe indexed image X

where X is a four-dimensional array of images that you want to use for the movie.

You can play the movie in MATLAB using the movie function.

This example loads the multiframe image mri.tif and makes a movie out of it. It won't do any good to show the results here, so try it out; it's fun to watch.

Note that immovie displays the movie as it is being created, so you will actually see the movie twice. The movie runs much faster the second time (using movie).

  Adding a Colorbar Displaying Multiple Images