MATLAB: 3D image stack; determine mean of individual arrays; error code

3d image stackMATLABmean

Hi,I have a 1000x1000x1952 uint8 3D image array (Array), and would like to get the mean value of each individual array "image" and subsequently put these in a 1952×1 array (meanArray).
The code I use is:
meanArray= mean(Array,[1 2])
the error code I get is: Error using sum "Dimension argument must be a positive integer scalar within indexing range. Error in mean (line 87) y = sum(x,dim,flag);"
What am I missing here? Thanks! Barry

Best Answer

For some reason, mean was not written to let you operate along multiple dimensions in the same call. One alternative is to use sepblockfun (Download).
[m,n,p]=size(Array);
meanArray = sepblockfun(Array, [m,n,1], 'mean');