two for loops problem
이전 댓글 표시
Hi everyone,
here i want to get pixel intensity out of a 512*512 image.
i wrote two for loops, but in the end in matrix 'intensityValue', l got only the last set of data.
the background is to get the coordinates from x and y. corx and cory are 41*75 matrices.
Thanks !
fluo = imread('fluo0020.tif');
% imshow(fluo);
corx=[];
cory=[];
intensityValue=[];
for i=1:length(coordinate)
A = [coordinate ; coordinate(1,:)] ;
if mod(i, 2) == 1
x= int16(A(:,i));
y= int16(A(:,(i+1)));
corx=[corx,x];
cory=[cory,y];
end
% scatter(x,y);
% line(x,y);
% hold all
end
for ttt=1:length(x)
xc=x(ttt,:);
xy=y(ttt,:);
inten=fluo(xc,yc);
intensityValue =[intensityValue;inten];
end
댓글 수: 3
Ameer Hamza
2020년 3월 6일
I don't fully understand the logic of this code, however, shouldn't the last part be,
for ttt=1:length(corx)
xc=corx(ttt,:);
xy=cory(ttt,:);
inten=fluo(xc,yc);
intensityValue =[intensityValue;inten];
end
yunwei hu
2020년 3월 6일
Ameer Hamza
2020년 3월 6일
Please check the one-liner in the answer to directly extract the value instead of writing a for loop.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!