File Exchange

image thumbnail


version (7.02 KB) by Oliver Woodford
Display multiple images as a montage of subplots


Updated 08 Jul 2014

View Version History

View License

This function combines the functionality of IMAGE, IMAGESC, IMSHOW and MONTAGE.
In particular, it improves upon the MONTAGE function in the Image Processing Toolbox in these ways:
- Image Processing Toolbox not required
- Images are placed in subplots, so can be zoomed separately.
- Small images are properly enlarged on screen.
- Gaps can be placed between images.
- Images can be viewed on a grid smaller than the number of images.
- Surplus images can be viewed by scrolling through pages.
- A directory of images can be viewed easily, by calling IMDISP with no arguments (a visual DIR).

To see two useful modes of operation try the following:

load mri
imdisp(D, bone(256));
imdisp(D, bone(256), 'Size', 1);

Use arrow keys to scroll through the image set with the single image.

This function is now included in the sc package:
The version here will not be maintained.

Cite As

Oliver Woodford (2021). imdisp (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (27)

Simone Scaringi

Hi Oliver, is it possible to display the resulta of the function inside the 'axes' component of a GUI? How? Thanks a lot for your work

Gil Weinberg

Hey, great m-file!
i wanted to add a feature adding the title of the figure i look at and used Jurgen comment from down here, just added the line:
to the M-file at the end of keypress_callback (@line 407, before the return).

Ngoc Nguyen


Hi Mr.Oliver

i would like to thank u for the great code
Can i know please how can i display the images in the same row (same y axis)
for example showing supermarkets products on shelves

i seek for your assistance


It would be nice to have the option of decently sized and placed colorbar with labeling.


Yi Sui

Yi Sui

Erik Bélanger


This tool is great, placing gaps between images is nice, exactly what I was looking for.

However, I noticed that gaps are doubled for every images that do not touch to outer borders of the montage. Single gaps are used for images lying around the montage.

For quick data screening it is fine but for building final montage figures it is a little annoying to have irregular spacing between images. Can it be fixed?


I made a small adjustment in imdisp today:
line 139 "lims = default_limits(A)" changed to lims = default_limits([I{:}])

This will ensure the colormap will cover the whole range of values in the images of cell array I.


Basic solution for caption:

Since I use size=1 alot, for me this gives a small title (default:in the lower left corner).

Get index with:

Venkat R

This tool is better than Matlab's montage. as it can display images unequal in size. Is it also possible to display such images in a standard size, instead of displaying in their truesizes? Because the small image displayed with a tall image looks unappealing for comparison.

thanking you



Excellent for reviewing fmri timeseries. It's been said, but yeh, frame number annotation would be great.

Daniel Lopes

Great piece of code! It is quite useful for processing medical images as one can see the several outputs of image filtering all at once or by scrolling them down in one figure. Not quite friendly to customize by adding extra graphical elements such as text, titles or lines.

Dan Knudsen

Amitabh Verma

Thanks Oliver, your work around works as well. But loading multi-frames a gig each tend to really slow things down. It would be nice to have (previous, current, next) pages loaded at a time. Maybe when you have some free time on you. Thanks again !

Oliver Woodford

Amitabh: I don't have time to do that, unfortunately. However, if you load the images yourself then it's easy to do. Put the two (or more) sets of images into a 2xN cell array, display them in a 1x2 grid, then page through a row at a time (up/down). This will give you the effect you want.

Amitabh Verma

I would like to make a feature request. I use imdisp to visually compare two images for which it works great. However, I am also dealing with multi-frame (time-lapse) tiff images. If there is an option to forward using the arrow keys like it does for single multi-frame images which forwards to the next frame for both/multiple loaded multi-frame images it would be greatly useful and appreciated. (Only needed where the size of multi-frame is same for the loaded images) Thanks !

Amitabh Verma

Thanks Oliver for the update. With the multi-frame support it works great now !

Amitabh Verma

I have a multipage tiff which I would like to use using imdisp but cannot seem to load all the pages using filename. Only the first image displays. Any help would be most appreciated. Thanks, works like a charm for everything else.

Yaroslav Bulatov

One gotcha is that one image in the grid can be rendered differently depending on other images in the array (related to scaling of intensity values perhaps?)

Shi vera

oh,i think this is a good idea to write some functions that what we really need!

Oliver Woodford

Displaying more than one image will clear the figure. Displaying a single figure will put it in the current axes.

The idea of having the filenames as captions is excellent, but there are a couple of issues that I can see which would significantly increase the complexity of the code, not least how and where to render the text so it is clearly visible, so I'm afraid I won't be doing it. I recommend someone giving it a try though.

Figure size is chosen to maximize image size of large images, or give integer magnification for small images (thus avoiding nearest-neighbour resizing artefacts). Layout is chosen to allow the largest image size possible. Note that this will not necessarily minimize the number of blank spaces. Both figure size and layout are based on the size of the first image. If you have an example of it doing a bad job please email me the images and test script.

Image Analyst

One note of warning. If you call this function from within your m-file code for your GUI, it will blow away everything on your GUI - it will not automatically pop up a new window. To avoid this, I simply put the lines
imdisp(montageCellArray, 'Border', [.01 .01]);
into my code. This will bring up a new blank figure (which will get replaced by the montage of images rather than my GUI.)

Secondly, I'd like to see the option of having the base file name as a caption on each image.

Third, it should do a better job of sizing the window. Mine pops up with the bottom edge under the Windows task bar, and tons of space on the right and left edge of the screen. Ideally there would be an option to size it to some fraction of the screen, such as 90% of the size in both x and y direction, or even fully maximized (no border).

Image Analyst

One note of warning. If you call this function from within your m-file code for your GUI, it will blow away everything on your GUI - it will not automatically pop up a new window. To avoid this, I simply put the lines
imdisp(montageCellArray, 'Border', [.01 .01]);
into my code. This will bring up a new blank figure (which will get replaced by the montage of images rather than my GUI.)
Looking forward to the captions....

Francis Burton

This function does exactly what I hoped and expected the original Image Processing Toolbox function to do, only much better and with some extra useful behavior - namely the ability to scroll through image sets. Mathworks could do worse than hire the author to write new, improved IPT functions.

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!