2011-02-25 91 views

回答

2

的一种方式是创建一个包含图像的10×10单元阵列,然后用CELL2MAT它们链状成一个大的图像。

nRows = 10; 
nCols = 10; 
imgCell = cell(nRows,nCols); 

for iImage = 1:nRows*nCols 

%# construct image name - fix this like so it conforms to your naming scheme 
%# also, add the path if necessary 
imageName = sprintf('image%i.jpg',iImage); 

%# add the image to imgCell 
%# images will filled first into all rows of column one 
%# then into all rows of column 2, etc 
imgCell{iImage} = imread(imageName); 

end 

%# if you want the images to be arranged along rows instead of 
%# columns, you can transpose imgCell here 
%# imgCell = imgCell'; 

%# catenate into big image 
bigImage = cell2mat(imgCell); 

%# show the result 
imshow(bigImage) 
+0

乔纳斯您好,感谢回答。您的编码将创建一个大图像,图像将在一行或一列中连接。我想要的是前10张图像应该在大合成图像的第一行中连接起来。接下来的10行第二行等等来完成10行。如果图像尺寸是400x400。生成的图像将是4000x4000。不是400x40000。如果我以前不清楚,我很抱歉。 – Shan 2011-02-25 13:03:26

+1

@Shan:我的代码应该通过创建一个4K的4K图像,如果有400 100张图片400,如果你运行的是它,即正确初始化imgCell。 – Jonas 2011-02-25 14:09:43

+0

@Jonas ...是的,它的工作..非常感谢 – Shan 2011-02-25 17:06:41