createImMontage (imarray, varargin)

Create a rectangular image montage or image grid from an image array
48 Downloads
Updated 24 Feb 2017

View License

A simple function and an alternative to Matlab Image processing Toolbox's montage(). It will produce an image as a grid of frames of the input image array instead of displaying. It also provides an option to resize the input images before adding them to the grid.
% --------------------------------------------------------------------------------
% Input arguments:
% 1st arg: imarray is input array of dimensions H x W x NumImages or H x W x C x NumImages where C
% is the number of channels in each image
% 2nd arg: gridcols = Number of images to appear horizontally
% Default = 3
% 3rd arg: dsf = Down Sampling Factor (to downsample or reduce the size of the input images)
% range [0 1]. Default = 1 (no downsampling)
% 4th arg: border = Thickness of border between two images (in pixels)
% Default = 2;
% ----------------------------------------------------
% Output argument:
% imMontage = output image montage or grid
% ----------------------------------------------------
% Examples:
% imMontage = createImMontage(imarray); % automatically select grid size and populate without any
% downsampling with 2 pixels border between consecutive images (default)
%
% imMontage = createImMontage(imarray,5,0.25); % 5 images horizontally and every
% image downsampled to quarter with 2 pixels border (default) between
% consecutive images
%
% imMontage = createImMontage(imarray,7,0.5,5); % 7 images horizontally and every
% image downsampled to half with 5 pixels border between consecutive images
%
% NOTE: Input image array can be created by:
% imarray = cat(3,imgray1,imgray2,imgray3,imgray4); % for gray scale images
% imarray = cat(4,imcolor1, imcolor2, imcolor4, imcolor5); for color images

Cite As

Wajahat Kazmi (2024). createImMontage (imarray, varargin) (https://www.mathworks.com/matlabcentral/fileexchange/61749-createimmontage-imarray-varargin), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008a
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!
Version Published Release Notes
1.0.0.0

.

.
.