imtile does not work with cell array of images
33 views (last 30 days)
Show older comments
Documentation for IMTILE says I can assign a cel array of images as an input variable.
This is instead what happens when I try to use it this way:
immag =
1×4 cell array
{1×1 Image} {1×1 Image} {1×1 Image} {1×1 Image}
>> otta=imtile(immag)
Error using images.internal.getImageFromFile (line 9)
The specified filename is not a string.
Thanks !
I add the whole tree of errors, it might be useful:
Error using images.internal.getImageFromFile (line 9)
The specified filename is not a string.
Error in images.internal.createMontage>getOneImage (line 339)
[I, map] = images.internal.getImageFromFile(imgSource{k});
Error in images.internal.createMontage>getImages (line 209)
img = getOneImage(imgSource,useIndexedRead, idxs(1), cmap);
Error in images.internal.createMontage (line 66)
imageArray = getImages( imgSrc, thumbnailSize, thumbnailInterp, ...
Error in imtile (line 9)
out = images.internal.createMontage(Isrc, thumbnailSize, thumbnailInterp, ...
0 Comments
Answers (3)
Star Strider
on 1 Jan 2026 at 11:49
It seems obvious --
immag =
1×4 cell array
{1×1 Image} {1×1 Image} {1×1 Image} {1×1 Image}
>> otta=imtile(immag)
Error using images.internal.getImageFromFile (line 9)
The specified filename is not a string.
See the imtile documentation section on filenames for details. They have to be file names of the images, not the images themselves.
0 Comments
Stephen23
on 1 Jan 2026 at 20:00
Edited: Stephen23
on 1 Jan 2026 at 20:01
"imtile does not work with cell array of images"
Yes, it does:
C = {rand(2,4,3),rand(2,4,3)};
I = imtile(C);
image(I)
The documentation here:
clearly states that it accepts a cell array of numeric images. My example above shows that this works exactly as documented. Your code does not work because you provided a cell array containing some kind of special class, which are clearly not numeric arrays.
0 Comments
DGM
on 1 Jan 2026 at 20:09
Edited: DGM
on 1 Jan 2026 at 20:15
You're feeding montage()/imtile() a cell array of graphics objects, not raster image arrays or filenames. I'm going to use montage() for this demonstration for simplicity, but the input handling is the same.
% these are filenames
fnameA = 'peppers.png';
fnameB = 'cameraman.tif';
% these are raster images (numeric arrays)
A = imread(fnameA);
B = imread(fnameB);
% these are graphics objects of type matlab.graphics.primitive.Image
objA = imshow(A); figure;
objB = imshow(B);
% montage()/imtile() work with filename inputs
figure;
montage({fnameA,fnameB})
% ... or with raster arrays
figure;
montage({A,B})
% but they do not accept graphics objects
figure;
montage({objA,objB})
You either need to extract the raster data from the objects, or better yet just use the original data instead.
% or something
montage({objA.CData,objB.CData})
0 Comments
See Also
Categories
Find more on Modify Image Colors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


