tdir = tempname();
mkdir(tdir);
numimg = 10;
imagenames = cell(numimg, 1);
for K = 1 : numimg
randimg = randi([0 255], 32, 32, 3);
imgnames{K} = fullfile( tdir, sprintf('image_%03d.png', K) );
imwrite(randimg, imgnames{K});
end
pause(20);
images = cell(numimg, 1);
for K = 1 : numimg
imgname = imagenames{K};
if ~exist(imgname, 'file')
fprintf('somehow a file went missing: "%s"\n', imgname);
images{K} = [];
else
images{K} = imread(imgname);
end
end
image4 = cat(4, images{:});
montage(image4);
Note:
If your only reason for reading them back in is to display them, then you can skip from "read that folder" onwards and instead use just
Best Answer