I have a 3D (x,y,nframes) matrix/ movie ( named ch), and a logical mask (x,y). I want to do the mean of the mask pixels in each frame , at the end I get a vector of dim 1xnframes. And I want to do it with the reshape instead than frame by frame, but both results doesn't match and I don't understand why... Could you please let me know why???
for i=1:nframes
ch_aux=ch(:,:,i);
Mean_for(i)= mean(ch_aux(mask));
end
% C with reshape
[row,col] = find(mask);
A=ch(row,col,:);
B=reshape(A,1,length(row).^2,nframes );
Mean_res=mean(B);
plot( Mean_for,'r')
hold on
plot( Mean_res(:))
legend({'for','reshape'})
thanks!