Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Montage() for Matlab and Octave
% note images must be exactly identically sized width x height
path = '~'
flist = {'1.png','2.png'}; % create this list with another function for real use
Nimg = length(flist);
finf = imfinfo([path,'/',flist(1).name]);
% this axis ordering needed by montage()
% third dimension is 1 for grayscale, 3 for color
oneorthree = 3;
data = zeros(finf.Height,finf.Width,oneorthree,Nimg);
for i = 1:Nimg
im = imread([path,'/',flist(i).name]);
data(:,:,oneorthree,i) = im;
end %for
% note optional 'DisplayRange' parameter to control contrast
montage(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment