在Matlab中构建一个图像数组 [英] Build an array of images in Matlab
问题描述
我正在做一个Matlab项目,我需要知道如何构建一个图像数组。
我需要能够以与C数组类似的格式移动数组某种指数。
I'm doing a Matlab project and I need to know how to build an array of images.
I need to have the ability to move through the array in a similar format as a C array with some kind of index.
我试过这个:
images = [image1 image2 image3 image4 image5];
但我收到此错误:
CAT参数尺寸不一致。
CAT arguments dimensions are not consistent.
我检查了尺寸(图片)
每个图像的方法,所有图像都来自同一维度。
I checked the size(image)
method for every one of the images and all of them are from the same dimension.
可能出现什么问题,或者我怎么能以其他方式做到这一点?
What could be wrong or alternatively how I can do this in other way?
谢谢。
推荐答案
有两种方法可以构建图像数组:
There are two ways you can build an array of images:
你可以沿着第三个维度连接你的图像(所有图像都应该是相同的尺寸),如下所示:
You catenate your images (all should be the same size) along the third dimension like so:
imgArray=cat(3,image1,image2,image3,...)
然后,您可以通过索引第三维来访问每个单独的图像。例如,
You can then access each individual image by indexing the third dimension. E.g.
image1=imgArray(:,:,1);
2。单元格数组
在这种情况下,您将图像分组为单元格数组,每个图像都包含在自己的单元格中。
2. A cell array
In this case, you group your images into a cell array, and each image is contained in its own cell.
imgCell={image1,image2,image3,...};
当您的图像尺寸不同时,这是一个不错的选择(唯一选择)。要访问每个单独的图像,您可以按如下方式索引单元格:
This is a good choice (the only choice) when your images are of different sizes. To access each individual image, you can index the cell as follows:
image1=imgCell{1};
这篇关于在Matlab中构建一个图像数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!