calculate 2D image from 3D data

1 次查看(过去 30 天)
MENGZHI DI
MENGZHI DI 2018-10-11
评论: MENGZHI DI 2018-10-12
Now I have the xyz data, and want to calculate the corresponding 2D image. The equations I am using is from shape from shading, I(i,j)=1/sqrt(p*p+q*q+1), p and q are the slope of the surface along the x and y directions, respectively. Here calculate them using discrete approximations, p=Z(i,j)-Z(i,j-1), q=Z(i,j)-Z(i-1,j). The result should be the above image, however what I get is the below one. Could someone give me some advice about this?
for i=1:numr
for j=1:numc
if (j==1)
p(i,j)=z(i,j+1)-z(i,j);
else
p(i,j)=z(i,j)-z(i,j-1);
end
if i==1
q(i,j)=z(i+1,j)-z(i,j);
else
q(i,j)=z(i,j)-z(i-1,j);
end
I(i,j)=1/sqrt(p(i,j)*p(i,j)+q(i,j)*q(i,j)+1);
end
end
  2 个评论
jonas
jonas 2018-10-11
Could you upload the xyz data?
MENGZHI DI
MENGZHI DI 2018-10-12
Thank you for replying. I put them in a 3x16384 matrix. The first row is x, second is y, third is z data.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by