montage - Display multiple image frames as rectangular montage

Syntax

montage(filenames)
montage(I)
montage(X, map)
montage(..., param1, value1, param2, value2, ...)
h = montage(...)

Description

montage(filenames) displays a montage of the images specified in filenames. filenames is an N-by-1 or 1-by-N cell array of filenames. If the files are not in the current directory or in a directory on the MATLAB path, you must specify the full pathname. See the imread command for more information. If one or more of the image files contains an indexed image, montage uses the colormap from the first indexed image file. montage arranges the frames so that they roughly form a square.

montage(I) displays all the frames of a multiframe image array I in a single image object. I can be a sequence of binary, grayscale, or truecolor images. A binary or grayscale image sequence must be an M-by-N-by-1-by-K array. A truecolor image sequence must be an M-by-N-by-3-by-K array.

montage(X, map) displays all the frames of the indexed image array X, using the colormap map for all frames. X is an M-by-N-by-1-by-K array.

montage(..., param1, value1, param2, value2, ...) returns a customized display of an image montage, depending on the values of the optional parameter/value pairs. See Parameters for a list of available parameters.

h = montage(...) returns the handle to the image object.

Parameters

The following table lists the parameters available, alphabetically by name. Parameter names can be abbreviated, and case does not matter.

Parameter

Value

'DisplayRange'

A 1-by-2 vector, [LOW HIGH] that controls the display range of each image in a grayscale sequence. The value LOW (and any value less than LOW) displays as black; the value HIGH (and any value greater than HIGH) displays as white. If you specify an empty matrix ([]), montage uses the minimum and maximum values of the images to be displayed in the montage as specified by 'Indices'. For example, if 'Indices' is 1:K and the 'DisplayRange' is set to [], the minimum value in I (min(I(:)) is displayed as black, and the maximum value (max(I(:)) is displayed as white.
Default: Range of the data type of I.

'Indices'

A numeric array specifying which frames to display in the montage. For example, to create a montage of the first four frames in I, enter montage(I,'Indices',1:4);. You can use this parameter to specify individual frames or skip frames. For example, the value 1:2:20 displays every other frame.
Default: 1:K, where K is the total number of frames to display.

'Size'

A 2-element vector, [NROWS NCOLS], specifying the number of rows and number of columns in the montage. You can use NaNs in the size vector to indicate that montage should calculate size in a particular dimension in a way that includes all the images in the montage. For example, if 'Size' is [2 NaN], the montage will have 2 rows, and the number of columns will be computed automatically to include all of the images in the montage. The images are displayed horizontally across columns.

Default: Calculated so the images in the montage roughly form a square.montage considers the aspect ratio when calculating the number of images to display horizontally and vertically.

Class Support

A grayscale image array can be logical, uint8, uint16, int16, single, or double. An indexed image can be logical, uint8, uint16, single, or double. The colormap must be double. A truecolor image can be uint8, uint16, single, or double. The output is a handle to the image object produced by montage.

Examples

Create a montage from a series of files. By default, montage arranges the images into a square.

fileFolder = fullfile(matlabroot,'toolbox','images','imdemos');
dirOutput = dir(fullfile(fileFolder,'AT3_1m4_*.tif'));
fileNames = {dirOutput.name}'
montage(fileNames);

Display the same set of images in two rows and five columns.

montage(fileNames, 'Size', [2 5]);

This example shows you how to customize the number of images in the montage and the contrast in the montage.

load mri
montage(D,map)

Create a new montage of the first 9 images.

figure
montage(D, map, 'Indices', 1:9);

Maximize the contrast of D without using the colormap.

figure
montage(D, 'DisplayRange', []);

See Also

immovie, imshow

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS