2011-02-25 89 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