Consider the following function, which takes a gray image (2D matrix) as input:
function r = fun1(img)
r = sum(sum(img));
I'm thinking of using arrayfun to process a series of images(3d matrix), thus eliminating the need for a for loop:
arrayfun(@fun1, imgStack);
But arrayfun tries to treat every element of imgStack as an input to fun1, the result of the previous operation also being a 3D matrix. How can I let arrayfun know that I want to repeat fun1 only on the 3rd dimension of imgStack?
Another question, does arrayfun invoke fun1 in parallel?
r=sum(img(:))