calculate 2D image from 3D data
1 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197567/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197569/image.png)
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!