How to refer current element index when using arrayfun

Hi All,
I need to simplify below loop which is used to create a 3D point cloud. I'm thinking to use something similar to arrayfun or bsxfun. Could you please let me know how to get the index of current element? For example, in below loop Fdx, Dx, Fdy and Dy are constants. And j is the column ID of pixel and i is the row ID of the pixel.
Any line of advice is much appreciated.
for i=1:480
for j=1:640
Xd(i,j) = (Zd(i,j)/Fdx)*(j-Dx);
Yd(i,j) = (Zd(i,j)/Fdy)*(i-Dy);
end
end

 채택된 답변

Matt J
Matt J 2018년 2월 15일
편집: Matt J 2018년 2월 15일
Xd=bsxfun(@times,Zd,((1:640)-Dx)/Fx);
Yd=bsxfun(@times,Zd,((1:480).'-Dy)/Fy);

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing and Computer Vision에 대해 자세히 알아보기

질문:

2018년 2월 15일

댓글:

2018년 2월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by