You are here : matlabImage Processingmontage

montage() - Image Processing

 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 single image object which contains all the frames displayed.ParametersThe following table lists the parameters available, alphabetically
by name. Parameter names can be abbreviated, and case does not matter.ParameterValue
 'DisplayRange' 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'Numeric array specifying which frames to display in the
montage. montage interprets the values as indices
into array I or cell array filenames.
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 or image files.
‘Parent'Handle of an axes that specifies the parent of the image object
created by montage.
'Size'Two-element vector, [NROWS NCOLS],
specifying the number of rows and number of columns in the montage.
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 two rows, and
the number of columns will be computed automatically to include all
of the images in the montage.  montage displays
the images 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.


Syntax

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


Example

Create Montage from Series of FilesOpen This Example
Create a list of filenames.fileFolder = fullfile(matlabroot,'toolbox','images','imdata');
dirOutput = dir(fullfile(fileFolder,'AT3_1m4_*.tif'));
fileNames = {dirOutput.name}'

fileNames = 

    'AT3_1m4_01.tif'
    'AT3_1m4_02.tif'
    'AT3_1m4_03.tif'
    'AT3_1m4_04.tif'
    'AT3_1m4_05.tif'
    'AT3_1m4_06.tif'
    'AT3_1m4_07.tif'
    'AT3_1m4_08.tif'
    'AT3_1m4_09.tif'
    'AT3_1m4_10.tif'

Display the sequence of images.montage(fileNames, 'Size', [2 5]);

Use DisplayRange Parameter to Highlight Image StructuresOpen This Example
Create a list of file names.fileFolder = fullfile(matlabroot,'toolbox','images','imdata');
dirOutput = dir(fullfile(fileFolder,'AT3_1m4_*.tif'));
fileNames = {dirOutput.name}'

fileNames = 

    'AT3_1m4_01.tif'
    'AT3_1m4_02.tif'
    'AT3_1m4_03.tif'
    'AT3_1m4_04.tif'
    'AT3_1m4_05.tif'
    'AT3_1m4_06.tif'
    'AT3_1m4_07.tif'
    'AT3_1m4_08.tif'
    'AT3_1m4_09.tif'
    'AT3_1m4_10.tif'

Display the sequence of images as a montage, using the DisplayRange parameter to highlight structures in the images.montage(fileNames, 'Size', [2 5],'DisplayRange', [75 200]);

Customize Number of Images in MontageOpen This Example
Load images.load mri
Display as montage.montage(D,map)

Create new montage containing only the first nine images.figure
montage(D, map, 'Indices', 1:9);


Output / Return Value


Limitations


Alternatives / See Also


Reference