0
我有編號從1到100,我想創建一個圖片從他們的一百個大小相等的RGB圖像。例如,如果我給行= 10和列= 10則輸出應該是這樣的,第一10個圖像將形成在第一行等等。如何在MATLAB中連接許多RGB圖像爲一個圖像?
我有編號從1到100,我想創建一個圖片從他們的一百個大小相等的RGB圖像。例如,如果我給行= 10和列= 10則輸出應該是這樣的,第一10個圖像將形成在第一行等等。如何在MATLAB中連接許多RGB圖像爲一個圖像?
的一種方式是創建一個包含圖像的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)
喬納斯您好,感謝回答。您的編碼將創建一個大圖像,圖像將在一行或一列中連接。我想要的是前10張圖像應該在大合成圖像的第一行中連接起來。接下來的10行第二行等等來完成10行。如果圖像尺寸是400x400。生成的圖像將是4000x4000。不是400x40000。如果我以前不清楚,我很抱歉。 – Shan 2011-02-25 13:03:26
@Shan:我的代碼應該通過創建一個4K的4K圖像,如果有400 100張圖片400,如果你運行的是它,即正確初始化imgCell。 – Jonas 2011-02-25 14:09:43
@Jonas ...是的,它的工作..非常感謝 – Shan 2011-02-25 17:06:41