Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

having trouble with mean2 function inside for loop

Asked by Alex on 2 Apr 2013

here is my code

img=read_LUM_all;
Lmask=mean(img,3);
Lmask(Lmask<415)=0;
Lmask(Lmask~=0)=1;
Lmask=logical(Lmask);
for i=1:13
    imgL(:,:,i)=read_LUM2;
    L(i)=mean2(imgL(Lmask));  % this line is only taking the mean of imgL(:,:,1), not imgL(:,:,i)
end
avgL=L(1:13)'

it reads in 13 files into a 3D array of size (1040x1392x13). I then average all the files to create a mask so that I can use that mask as an ROI to get an average value of each individual file over the ORI created by the average mask. I eventually want a 13x1 array (avgL) that has the average value over the ROI of each image and right now I am getting a 13x1 array that gives me the average of only the first frame.

0 Comments

Alex

Tags

Products

No products are associated with this question.

1 Answer

Answer by Jan Simon on 2 Apr 2013
Edited by Jan Simon on 2 Apr 2013
Accepted answer
imgL = reshape(imgL, 13);
L(i)=mean2(imgL(Lmask, i));

0 Comments

Jan Simon

Contact us