You can simply combine all images (each of which is a 3D
matrix for color images) into a 4D
matrix with last dimension is the total number. And save this 4D
matrix to a .mat
file for later loading.
For grayscale images, you only need to combine them into a 3D
matrix as each of which is 2D
.
As commented by @Divakar, you may need to combine them into a cell array if the sizes of the images are not consistent.
Edit: Suppose you have combined the images into a 3D/4D
matrix called data
, you can use save data;
to save it into disk and use load data;
to load it back.