imtile does not work with cell array of images
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(3 个)
Star Strider
2026-1-1
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 个评论
Stephen23
2026-1-1
编辑:Stephen23
2026-1-1
"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 个评论
DGM
2026-1-1
编辑:DGM
2026-1-1
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



