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.
I tried it with this:
images = [image1 image2 image3 image4 image5];
but I get this error:
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?
thanks.
There are two ways you can build an array of images:
1. A 3D array
You catenate your images (all should be the same size) along the third dimension like so:
You can then access each individual image by indexing the third dimension. E.g.
2. A cell array
In this case, you group your images into a cell array, and each image is contained in its own cell.
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: