title: Matlab read images stored in 4D array
body: <p>I have been experimenting in Matlab using PCA on different image face databases. I recently acquired several databases from colleague which he acquired years ago. They are .mat files, when I double click the .mat file, the following files are shown</p>
  
  <p><img src="https://i.stack.imgur.com/3WgcJ.png" alt="enter image description here"></p>
  
  <p>As you can see the images are stored in this dbface 4D array variable but I am unsure as to how to extract each individual image. I have only been using matlab for few weeks so still getting familiar with it. I have been searching around, but can't find any examples as to how you are meant to extract each individual image from a 4D array.</p>
  
  <p>Any help would be much appreciated</p>
  
  <p>Edit:</p>
  
  <pre><code>size(dbface)
  
  ans =
    64    64    11    15
  
  If anyone else encounters this, easiest way to extract is to do the following
  
  %Return rows cols and dimensions
  [rows cols dimen1 dimen2] = size(dbface);
  
  count = 0;
  %Loop through each image
  for i = 1:dimen1
  for j = 1:dimen2
  count = count + 1;
  image = dbface(:,:,i,j);
  tmimg=uint8(image); 
  img=reshape(tmimg,cols,rows);   
  images{count} = img;
  end
  end
  </code></pre>