I've imported a set of images in MATLAB, and I've converted them to grayscale. I must now create an image stack, "a 3D matrix of grayscale images". After this, I must create a 1D image intensity array by taking the "double mean of each layer of the image stack". Here is my code thus far (I import just a few images):
for i=139:141
string2 = num2str(i);
% Concatenate several strings, produce file name
str = [string, string2, string3];
% Read image
a = imread(str);
% Get image dimensions
size(a)
% Convert to grayscale
b = rgb2gray(a);
'size(a)' yields '1728 x 2592 x 3'. This is true for all images. I'm wondering how I can create the 3D matrix of grayscale images, and I'm wondering how I can create the 1D image array mentioned above. I'm assuming, perhaps incorrectly, that "double mean" means
mean(mean(...)).
For the 3D matrix, I have
% Pre-allocate 3D matrix
ImStack = zeros(1728, 2592, 3, class(b));
% Add images to ImStack
ImStack(:,:,1) = b;
This follows a template I found on the MathWorks help forum,
b= zeros(2000,2000,number_of_images,class(a));
b(:,:,1) = a;
However, I am unsure how to proceed with creating the 1D image intensity array. Your advice would be greatly appreciated. Thank you.